How is everyone today?.
Well I just recently jumped into
VB and as well as dealing with
VB inserting data to an MS Access database.
The problem I have is this....
First and foremost I'm making a simple form which has 1 text box
and 1 button. I just Need to know how to insert the data to the database.
So far Im trying to coded it manually instead of using the wizard and I can tell you where I'm stuck at.
I will show the code and then you can tell me what am I doing wrong or what step am I missing.
''''''''''''''''''''''''''''''''''''''''
Dim strConnectionString As String = _
"Provider = Microsoft.Jet.OLEDB.4.0" & _
"Data Source = C:\db2.mdb"
Dim objConnection As New OleDbConnection(strConnectionString)
'Now to open a connection
Try ' The reason we use try is to see if the database can open and what can happen
objConnection.Open()
Debug.WriteLine(objConnection.State.ToString)
Catch OleDbExceptionErr As OleDbException
Debug.WriteLine(OleDbExceptionErr.Message)
Catch InvalidOperationExceptionErr As InvalidOperationException
Debug.WriteLine(InvalidOperationExceptionErr.Messa ge)
End Try
Dim txtStr = txtName.Text
Dim strSQL As String = _
"Insert INTO db2.Names( First) values (txtStr)"
Dim objCommand As New OleDbCommand(strSQL, objConnection)
'* From here Im stuck and I dont know what else to do *'
As you can see by the code its very simple to follow, but I m having such a hard time just to insert 1 simple input...then again what is simple to some is hard for others LOL
Well if anyone can lead the correct way please let me know.
Thank you in advance.
From : theNewVB Noob :)