i have some doubts to connect vb with databse.so anybody help me hw to connect this two.

Re: want a help 80 80

You can use Data control to connect a database to a project.

Re: want a help 80 80

can you specify what is your doubt. also post how u r trying to connect vb to database.

Re: want a help 80 80

Inserting a new record and updating a record using the Execute command in Visual Basic.

We can use the SQL Insert statement to issue a command that will add a new record in a data source.

Option Explicit
Dim CN As Connection
Dim comobj As Command

Private Sub Form_Load()
Set CN = New Connection
Set comobj = New Command

With CN
.ConnectionString = “Integrated Security=SSPI;Initial Catalog=FinAccounting;Data Source=SYS1”
.Provider = “SQLOLEDB”
.Open
End With
With comobj
.ActiveConnection = CN
.CommandText = “INSERT INTO AccountsTable(AccountCode,AccountName,AccountCat) values(‘C001’,’Creditor1',’1')”
.Execute
End With
End Sub

Updating Records

You can use the SQL Update statement to issue a command that changes a record or group of records.

Option Explicit
Dim CN As Connection
Dim comobj As Command

Private Sub Form_Load()
Set CN = New Connection
Set comobj = New Command

With CN
.ConnectionString = “Integrated Security=SSPI;Initial Catalog=FinAccounting;Data Source=SYS1”
.Provider = “SQLOLEDB”
.Open
End With

With comobj
.ActiveConnection = CN
.CommandText = “UPDATE AccountsTable SET AccountName =’Main Creditor1' WHERE AccountCode=’C001'”
.Execute
End With

End Sub

Re: want a help 80 80

use the adodc component in vb,it is very easy to learn.go to your components and click adodc control and datagrid control to display your data.
hope this helps....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.