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. ConnectionString Problem (Urgent HELP required)

ConnectionString Problem (Urgent HELP required)

Scheduled Pinned Locked Moved Database
helpdatabasequestion
10 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.
  • S Offline
    S Offline
    Sadaf Naeem
    wrote on last edited by
    #1

    hello 2 all the problem that I am facing these days is that I am using oleDbConnection in my application. the database that I am using in my application resides in the solution folder. everytime I take this application to other computer, I have to change the connection string which I dont want to how can I overcome this problem. :(( :confused::confused::confused: I will appreciate if someone help me in resolving the issue. Thanks in advance :-D

    Sadaf

    P 1 Reply Last reply
    0
    • S Sadaf Naeem

      hello 2 all the problem that I am facing these days is that I am using oleDbConnection in my application. the database that I am using in my application resides in the solution folder. everytime I take this application to other computer, I have to change the connection string which I dont want to how can I overcome this problem. :(( :confused::confused::confused: I will appreciate if someone help me in resolving the issue. Thanks in advance :-D

      Sadaf

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      First of all, don't mark your posts as URGENT. You're not paying anyone for their help, so be prepared to wait. You haven't stated what type of database you are using. Presumably it is file-based, Access maybe?

      Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

      S 1 Reply Last reply
      0
      • P pmarfleet

        First of all, don't mark your posts as URGENT. You're not paying anyone for their help, so be prepared to wait. You haven't stated what type of database you are using. Presumably it is file-based, Access maybe?

        Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

        S Offline
        S Offline
        Sadaf Naeem
        wrote on last edited by
        #3

        I am really sorry if I sound rude but that was not my purpose to mark my post URGENT . the only purpose to do that was I have to show it to my supervisor and I just want the people to know that I want their help instantly but I AM REALLY VERY SORRY :( :( :( I will make sure it never happens again I am using MS ACCESS 2003... thanks 4 ur kind help

        Sadaf

        P 1 Reply Last reply
        0
        • S Sadaf Naeem

          I am really sorry if I sound rude but that was not my purpose to mark my post URGENT . the only purpose to do that was I have to show it to my supervisor and I just want the people to know that I want their help instantly but I AM REALLY VERY SORRY :( :( :( I will make sure it never happens again I am using MS ACCESS 2003... thanks 4 ur kind help

          Sadaf

          P Offline
          P Offline
          pmarfleet
          wrote on last edited by
          #4

          Connection strings for Access require an absolute path to the database file. You will need to construct connection string with the path to the database file yourself in code. You can get the path that your application is executing from by calling Environment.CurrentDirectory. Then append the name of your Access database file.

          Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

          S 4 Replies Last reply
          0
          • P pmarfleet

            Connection strings for Access require an absolute path to the database file. You will need to construct connection string with the path to the database file yourself in code. You can get the path that your application is executing from by calling Environment.CurrentDirectory. Then append the name of your Access database file.

            Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

            S Offline
            S Offline
            Sadaf Naeem
            wrote on last edited by
            #5

            Thanks a lot I will try it today :-D

            Sadaf

            1 Reply Last reply
            0
            • P pmarfleet

              Connection strings for Access require an absolute path to the database file. You will need to construct connection string with the path to the database file yourself in code. You can get the path that your application is executing from by calling Environment.CurrentDirectory. Then append the name of your Access database file.

              Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

              S Offline
              S Offline
              Sadaf Naeem
              wrote on last edited by
              #6

              thanks 4 ur kind help I tried it but not there is a 2nd problem which is as follows: my code is: string currentDirectory = System.Environment.CurrentDirectory; OleDbConnection con = new OleDbConnection(); con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" + currentDirectory + "\\dbLetters.mdb';Persist Security Info=False"; this.oleDbInsertCommand1.Connection = con; //other parameters this.oleDbInsertCommand1.Parameters["Subject"].Value = this.txtSubject.Text; this.oleDbInsertCommand1.Parameters["RefNumber"].Value = this.txtRefNumber.Text; this.oleDbInsertCommand1.Parameters["RefDate"].Value = this.dateTimePicker1.Value; this.oleDbInsertCommand1.Parameters["OutwardNumber"].Value = this.txtOutwardNumber.Text; this.oleDbInsertCommand1.Parameters["OutwardDate"].Value = this.dateTimePicker2.Value; this.oleDbInsertCommand1.Parameters["FileNumber"].Value = this.txtFileNumber.Text; this.oleDbInsertCommand1.Parameters["Remarks"].Value = this.txtRemarks.Text; con.Open(); this.oleDbInsertCommand1.ExecuteNonQuery(); con.Close(); ------------------------------- Upon execution , it is not creating a new record but always updating the last record and I have no clue to why is this happening. :( Plz guide me . I shall be really thankful 2 u

              Sadaf

              1 Reply Last reply
              0
              • P pmarfleet

                Connection strings for Access require an absolute path to the database file. You will need to construct connection string with the path to the database file yourself in code. You can get the path that your application is executing from by calling Environment.CurrentDirectory. Then append the name of your Access database file.

                Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

                S Offline
                S Offline
                Sadaf Naeem
                wrote on last edited by
                #7

                INSERT INTO tblOutgoingLetters ([To], [From], Subject, RefNumber, RefDate, OutwardNumber, OutwardDate, FileNumber, Remarks) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) this is the command that I have in the CommandText property of Command object..but instead of inserting a new record into the table , it is changing the content i.e. updating the last record Do u have any idea about why is this problem occurring?

                Sadaf

                1 Reply Last reply
                0
                • P pmarfleet

                  Connection strings for Access require an absolute path to the database file. You will need to construct connection string with the path to the database file yourself in code. You can get the path that your application is executing from by calling Environment.CurrentDirectory. Then append the name of your Access database file.

                  Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

                  S Offline
                  S Offline
                  Sadaf Naeem
                  wrote on last edited by
                  #8

                  EVERY TIME I OPEN THE SOLUTION FILE TO MAKE SOME CHANGES IN MY PROJECT , THE RECORDS ADDED AFTER USING ENVIRONMENT.CURRENTDIRECTORY ARE DELETED . HOWEVER THE RECORDS THAT WERE INSERTED INTO THE DATABASE BEFORE I USED THIS REMAIN AS IT IS. WHAT COULD BE THE CAUSE?:confused:

                  Sadaf

                  P 1 Reply Last reply
                  0
                  • S Sadaf Naeem

                    EVERY TIME I OPEN THE SOLUTION FILE TO MAKE SOME CHANGES IN MY PROJECT , THE RECORDS ADDED AFTER USING ENVIRONMENT.CURRENTDIRECTORY ARE DELETED . HOWEVER THE RECORDS THAT WERE INSERTED INTO THE DATABASE BEFORE I USED THIS REMAIN AS IT IS. WHAT COULD BE THE CAUSE?:confused:

                    Sadaf

                    P Offline
                    P Offline
                    pmarfleet
                    wrote on last edited by
                    #9

                    Please don't shout. Pay attention to forum rule no. 6

                    Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

                    K 1 Reply Last reply
                    0
                    • P pmarfleet

                      Please don't shout. Pay attention to forum rule no. 6

                      Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

                      K Offline
                      K Offline
                      Khawar Abbas1
                      wrote on last edited by
                      #10

                      This is actually a problem with you program logic. Insert statement can never update another record. So check your logic may be on insertion the program calls the update function.

                      Do good and have good.

                      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