Im new to using databases in my programming and to be honeest i am struggling.
i need to get the program to communicate with my database to allow the user to login
this is the code i have so far as i say i dont know much about it so its a bit bodged.
Private Sub Connecttodb() Dim con As New OleDb.OleDbConnection 'This Allows a Connection To a Database Dim dbProvider As String 'This Will Be The Provider For the Database Dim DataSet As New DataSet 'This Will Effectively Store The Database Dim DataAdapter As OleDb.OleDbDataAdapter 'Allows manipulation and access of database Dim Sql As String 'This Is The Query String dbProvider = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Ollie\Desktop\Spelling Bee\SpellingBeeDB.accdb;Jet OLEDB:Database" 'Points The Provider to the location of the database con.ConnectionString = dbProvider 'this creates a connection to the database provider con.Open() 'Opens A Connection Stream Sql = "SELECT *, FROM Userinfo" DataAdapter = New OleDb.OleDbDataAdapter(Sql, con) 'Uses DataAdapater constructor to take the appropriate query and from which connection DataAdapter.Fill(DataSet, "UserInfo") 'fill the data set with everything from the dataAdapter and call the table UserInfo con.Close() 'Close connection stream UsernameTextBox = DataSet.Tables("UserInfo").Rows(1).Item(1)
So my question is is there a simpler more efficent approach or can anyone see where im going wrong?