Skip to main content

Write a VB Program to accept the details of Company from user & store those details in to the database. (Don t use Standard controls) Company having fields ccode, cname, cadddress, cphno

· One min read
Kaustubh Kulkarni
file.vb
Dim ad As ADODB.Connection  
Dim rst As ADODB.Recordset
Dim sql As String

Private Sub Command1_Click() 'Add New

Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End Sub
Private Sub Command2_Click() 'Save
rst.AddNew
rst!empcode = CInt(Text1.Text)
rst!empname = Text2.Text
rst!salary = CDbl(Text3.Text)
rst!doj = CDate(Text4.Text)
rst.Update
rst.Requery
MsgBox ("Data Inserted")
End Sub

Private Sub Command3_Click()
rst.MoveFirst
Call loadData
End Sub

Private Sub Command4_Click()
rst.MoveLast
Call loadData
End Sub

Private Sub Form_Load()
Set ad = New ADODB.Connection

ad.ConnectionString = "DSN=DBemp" 'must be created before use from control panel
ad.Open
MsgBox ("Open")