Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL database

SQL database

Scheduled Pinned Locked Moved Database
csharpdatabasevisual-studiosysadminsecurity
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Emejulu JVT
    wrote on last edited by
    #1

    Pls guys, i wrote some code which is supposed to be installed on other computers. but when i finished, it could only run on my system, and generates SQL database errors when installed on other systems. the code was written in C#, i used the sql compact server that comes with visual studio 2008.this is how i wrote the connection string:

    private static string connectionString()
    {
    string conString = @"Data Source=|DataDirectory|\electionsoft.sdf;Password=emejulu.4190;Persist Security Info=True";
    return conString;
    }

       private void openConnection()
       {
           if(con.State == ConnectionState.Closed)
               con.Open();
       }
    
    G S 2 Replies Last reply
    0
    • E Emejulu JVT

      Pls guys, i wrote some code which is supposed to be installed on other computers. but when i finished, it could only run on my system, and generates SQL database errors when installed on other systems. the code was written in C#, i used the sql compact server that comes with visual studio 2008.this is how i wrote the connection string:

      private static string connectionString()
      {
      string conString = @"Data Source=|DataDirectory|\electionsoft.sdf;Password=emejulu.4190;Persist Security Info=True";
      return conString;
      }

         private void openConnection()
         {
             if(con.State == ConnectionState.Closed)
                 con.Open();
         }
      
      G Offline
      G Offline
      GenJerDan
      wrote on last edited by
      #2

      What errors? What OS on the target? Did you actually set the DataDirectory value somewhere? (Or did you forget to do that like I forgot to do that a while back?)

      I thought you had to go to Pittsburgh for that. My Mu[sic] My Films My Windows Programs, etc.

      E 1 Reply Last reply
      0
      • E Emejulu JVT

        Pls guys, i wrote some code which is supposed to be installed on other computers. but when i finished, it could only run on my system, and generates SQL database errors when installed on other systems. the code was written in C#, i used the sql compact server that comes with visual studio 2008.this is how i wrote the connection string:

        private static string connectionString()
        {
        string conString = @"Data Source=|DataDirectory|\electionsoft.sdf;Password=emejulu.4190;Persist Security Info=True";
        return conString;
        }

           private void openConnection()
           {
               if(con.State == ConnectionState.Closed)
                   con.Open();
           }
        
        S Offline
        S Offline
        S Douglas
        wrote on last edited by
        #3

        Emejulu JVT wrote:

        Source=|DataDirectory|\electionsoft.sdf

        Where does the 'DataDirectory' get put at? It's likely to be a permissions issue on Vista / Windows 7 if this is in the program files directory. Just guessing here as the actual error message was not included in the post.


        Common sense is admitting there is cause and effect and that you can exert some control over what you understand.

        1 Reply Last reply
        0
        • G GenJerDan

          What errors? What OS on the target? Did you actually set the DataDirectory value somewhere? (Or did you forget to do that like I forgot to do that a while back?)

          I thought you had to go to Pittsburgh for that. My Mu[sic] My Films My Windows Programs, etc.

          E Offline
          E Offline
          Emejulu JVT
          wrote on last edited by
          #4

          The OS i'm using is Win7. How do i set the DataDirectory value

          G 1 Reply Last reply
          0
          • E Emejulu JVT

            The OS i'm using is Win7. How do i set the DataDirectory value

            G Offline
            G Offline
            GenJerDan
            wrote on last edited by
            #5

            Put this somewhere where it will run before doing any database stuff:

            AppDomain.CurrentDomain.SetData("DataDirectory", System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData));//LocalApplicationData));

            Depending on whether you're installing for "everyone" or for each individual user, choose the CommonApplicationData or LocalApplicationData "SpecialFolder" there at the end. And, of course, that's where the database file has to sit. (which makes debugging from within Visual Studio a pain in the butt.)

            I thought you had to go to Pittsburgh for that. My Mu[sic] My Films My Windows Programs, etc.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups