Latest News

the latest news from our team

ODBC VB.NET Sample

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

TextBox1.Text = “busy…”
Application.DoEvents()

rs.MoveNext()

If rs.EOF Then
TextBox1.Text = “EOF”
TextBox2.Text = ” ”
TextBox3.Text = ” ”
Exit Sub
End If

TextBox1.Text = rs.Fields(0).Value
If (Not IsDBNull(rs.Fields(1).Value)) Then
TextBox2.Text = rs.Fields(1).Value
Else
TextBox2.Text = “null”
End If
If (Not IsDBNull(rs.Fields(1).Value)) Then
TextBox3.Text = rs.Fields(2).Value
Else
TextBox3.Text = “null”
End If

End Sub

 


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

conn.Open(“DSN=mscard0000”)

rs.Open(“select item_no, SALES_HISTORY_1, SALES_HISTORY_2 from history”, conn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

rs.MoveFirst()

Label1.Text = rs.Fields(0).Name
Label2.Text = rs.Fields(1).Name
Label3.Text = rs.Fields(2).Name

TextBox1.Text = rs.Fields(0).Value
TextBox2.Text = rs.Fields(1).Value
TextBox3.Text = rs.Fields(2).Value

End Sub

 


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

rs.AddNew()

rs.Fields(0).Value = TextBox1.Text
rs.Fields(1).Value = TextBox1.Text
rs.Fields(2).Value = TextBox1.Text

rs.Update()

TextBox1.Text = ” ”
TextBox2.Text = ” ”
TextBox3.Text = ” ”

End Sub

 


Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

rs.Requery()
rs.MoveFirst()

TextBox1.Text = rs.Fields(0).Value
TextBox2.Text = rs.Fields(1).Value
TextBox3.Text = rs.Fields(2).Value

End Sub

 


Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

Dim rs2 As New ADODB.Command()
Dim x1 As ADODB.Parameter
Dim x2 As ADODB.Parameter
Dim x3 As ADODB.Parameter

rs2.ActiveConnection = conn

rs2.CommandText = (“INSERT INTO history ( ITEM_NO,SALES_HISTORY_1,SALES_HISTORY_2) VALUES(?,?,?)”)

rs2.Parameters(0).Value = TextBox1.Text
rs2.Parameters(1).Value = TextBox1.Text
rs2.Parameters(2).Value = TextBox1.Text

rs2.Execute()

End Sub

 

Leave a Reply

Your email address will not be published. Required fields are marked *