I can insert into my table by the bindingnavigator and dragging textboxes straight from the DataSet entering them and saving. But I want to insert into the DataBase via code and in order to do this I have used the below code to connect. I use this code to test the connection and cannot get it to connect. Just get the error to say the DB cannot be found.
No username or password on the DB
Any ideas or am I missing something? Thanks,
Private Sub btnDB_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDB.Click Dim connString As String = "Data Source=C:\Visual Studio 2008\Projects\CollegeBetfair\BetfairDB.sdf" Dim myDB As New SqlConnection(connString) Try myDB.Open() Catch ex As Exception MessageBox.Show(ex.Message) End Try If myDB.State = 1 Then MessageBox.Show("Connected") End If End Sub