Database Connection

PLH

Well-known member
Joined
Dec 18, 2004
Messages
48
Location
Los Angeles, CA - USA
Programming Experience
Beginner
Hi there, I have a very odd problem with my app. The problem is that when I establish a database connection through the Server explore and add an setup project to it, after I install the app to target computer I get an error which says that the database is missing. It seems that the path which connects to the database is the same as in my development computer. My question is how should I configure the database connection that will have the connection path pointing to the database in the client computer (in the app folder)?

Thanks for your help!
 
Last edited:
However, you need a string connection that will have as you said connection path pointing to the database in the client computer (in the app folder).

For instance:

VB.NET:
Public con AsString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "/database.mdb; Persist Security Info=False;"
  
Public oledbcon AsNew OleDbConnection(con)

Cheers ;)
 
Personally, i'm declaring all that within module item as probably you would reuse the same connection at least couple times so, it's up to you ... but my suggestion would be module .. that's why i declared that with Public scope ... Otherwise you should declare on every form you need to use certain conn or make it shared

Cheers ;)
 
Thanks for your replies. Now I am having another problem, how should I bind a comboBox. In my code I have

With CustomerLookup

.DataSource = DsNorthwind1.DisplayMember = "Customers.CompanyName"

.ValueMember = "Customers.CustomerID"

.DataBindings.Add(New Binding("SelectedValue", DsNorthwind1, "Orders.CustomerID"))

End With

which I got from MSDN library but it doesn’t work well. I can’t go through the records; it freezes on the second record that was chosen from comboBox. It works well when I erase this part.

.DataBindings.Add(New Binding("SelectedValue", DsNorthwind1, "Orders.CustomerID"))

I don’t know why but it works. Anyway, the major problem I have is the cancel button. The problem is that when the user clicks the cancel button which uses the daCustomer.Fill(Ds, "Customer") method to cancel any changes that are made with customer record, the comboBox doubles the records (one more copy of customers’ records)
 
PLH said:
Thanks for your replies. Now I am having another problem, how should I bind a comboBox. In my code I have

With CustomerLookup

.DataSource = DsNorthwind1.DisplayMember = "Customers.CompanyName"

.ValueMember = "Customers.CustomerID"

.DataBindings.Add(New Binding("SelectedValue", DsNorthwind1, "Orders.CustomerID"))

End With

which I got from MSDN library but it doesn’t work well. I can’t go through the records; it freezes on the second record that was chosen from comboBox. It works well when I erase this part.

.DataBindings.Add(New Binding("SelectedValue", DsNorthwind1, "Orders.CustomerID"))

I don’t know why but it works. Anyway, the major problem I have is the cancel button. The problem is that when the user clicks the cancel button which uses the daCustomer.Fill(Ds, "Customer") method to cancel any changes that are made with customer record, the comboBox doubles the records (one more copy of customers’ records)
Please ask new questions in new threads, unless they follow directly from the original question, which this doesn't.

Thanks
 
Back
Top