Sir,
I am using front end as a VB.net 2005 and I am a beginner in this language. I am creating Desktop application and using controls TAB controls 1st tab control is Contact in contact I am using one text box, two button and one datagrid while I am using the oledb database i am inserting the data through text box and correspondingly that data will display on datagrid and there is my following coding to add contact.
In the contactdb file i have created contact table and the fields are ContactID and ContactName
Private Sub AddContact()
Try
Dim myDataSet As DataSet = New DataSet()
Dim cmd As OleDbCommand
Dim con As OleDbConnection
Dim str As String
'Dim da As New OleDbDataAdapter
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Contactdb.mdb"
con = New OleDbConnection(connectionString)
cmd = New OleDbCommand("insert into Contact(ContactName) values(ContactName)", con)
With cmd.Parameters
.Add("@ContactName", OleDbType.VarChar).Value = connametxtbox.Text
End With
con.Open()
cmd.ExecuteNonQuery()
con.Close()
' Close and Clean up objects
DataGridView1.DataSource = myDataSet.Tables("Contact").DefaultView
con.Dispose()
cmd.Dispose()
Catch ex As OleDbException
MsgBox(ex.Message.ToString)
insertOk = False
End Try
If insertOk Then
MsgBox("Contact Submitted Successfully!")
Else : MsgBox("There was an error saving your data!")
End If
End Sub
1) The problem is that while inserting data through text box it will insert but it will not display on my MS access file i.e. Contactdb what is the reason behind that please guide me for that please.
2) That the data in datagrid i.e. contact name by selecting the contact name it will display in the text box by datagrid cell click event by using this i want to update the contact name only. How I can update the Contact Name please guide me.
where is my mistake is going on.
Thanks in advance