It depends on what type of data base you are using i.e MS Access, SQL Server, Oracle and so on.
Because depend on that your connection String and some part of code will change.
To refer Connection Strings for different types of data base see the following link :
http://www.connectionstrings.com/[
^]
Code Example to Insert Data In SQL Database :
Dim _objConnection As SqlClient.SqlConnection
_objConnection = New SqlClient.SqlConnection("Your Connection String goes here")
_objConnection.Open()
Dim _mCommand As String
_mCommand = "Insert Into TableName(Column1, Column2) Values (@Column1, @Column2)"
Dim _objCommand As New SqlClient.SqlCommand(_mCommand, _objConnection)
_objCommand.Parameters.AddWithValue("@Column1", "Value To Insert")
_objCommand.Parameters.AddWithValue("@Column2", "Value To Insert")
_objCommand.ExecuteNonQuery()
_objConnection.Close()
_objCommand.Dispose()
Code Exaple To Insert Data Into Access Database :
Dim _objConnection As OleDb.OleDbConnection
_objConnection = New OleDb.OleDbConnection("Your Connection String goes here")
_objConnection.Open()
Dim _mCommand As String
_mCommand = "Insert Into TableName(Column1, Column2) Values (@Column1, @Column2)"
Dim _objCommand As New OleDb.OleDbCommand(_mCommand, _objConnection)
_objCommand.Parameters.AddWithValue("@Column1", "Value To Insert")
_objCommand.Parameters.AddWithValue("@Column2", "Value To Insert")
_objCommand.ExecuteNonQuery()
_objConnection.Close()
_objCommand.Dispose()
For other type of database Google is there. :)
I hope it will help you. :)