ConnectionString Problem (Urgent HELP required)
-
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
-
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
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
-
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
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
-
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
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
-
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
Thanks a lot I will try it today :-D
Sadaf
-
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
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
-
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
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
-
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
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
-
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
-
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
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.