VB – ORACLE CONNECTION CODE (Dynamic)Include ADODB Component:Project à Reference à Microsoft ActiveX Data Objects 2.8 Library------------------------------------------Code for INSERT-----------------------------------------------------Private Sub Command1_Click()Dim MyConn As ADODB.ConnectionSet MyConn = New ADODB.ConnectionDim MyRecSet1 As New ADODB.RecordsetMyConn.ConnectionString = "DSN=conOracle;User Id=scott;Password=tiger;"MyConn.OpenSet MyRecSet1 = MyConn.Execute("INSERT INTO Student VALUES(" & Val(Text1.Text) & ",'" & Text2.Text & "')")MyConn.CloseMsgBox ("Add Successfully")Text1.Text = ""Text2.Text = ""End Sub------------------------------------------Code for Display-----------------------------------------------------Private Sub Command2_Click()Dim conn As ADODB.ConnectionDim rs As ADODB.RecordsetSet rs = New ADODB.RecordsetSet conn = New ADODB.ConnectionDim i As Integerconn.ConnectionString = "DSN=conOracle;User Id=scott;Password=tiger;"conn.OpenSet rs = conn.Execute("select * from Student")Text1.Text = rs.Fields(0).ValueText2.Text = rs.Fields(1).ValueWhile Not rs.EOFi = i + 1'MsgBox (rs.Fields("rollno").Value)'MsgBox (rs.Fields("name").Value)rs.MoveNextWendrs.Closeconn.CloseMsgBox ("no of row = " & i)End Sub------------------------------------------Code for Update-----------------------------------------------------Private Sub Command3_Click()Dim MyConn As ADODB.ConnectionSet MyConn = New ADODB.ConnectionDim MyRecSet1 As New ADODB.RecordsetMyConn.ConnectionString = "DSN=conOracle;User Id=scott;Password=tiger;"MyConn.OpenSet MyRecSet1 = MyConn.Execute("UPDATE Student SET NAME='" & Text2.Text & "' WHERE ROLLNO=" & CInt(Trim(Text1.Text)) & "")MyConn.CloseMsgBox ("Update Successfully")Text1.Text = ""Text2.Text = ""End Sub------------------------------------------Code for DELETE-----------------------------------------------------Private Sub Command4_Click()Dim MyConn As ADODB.ConnectionSet MyConn = New ADODB.ConnectionDim MyRecSet1 As New ADODB.RecordsetMyConn.ConnectionString = "DSN=conOracle;User Id=scott;Password=tiger;"MyConn.OpenSet MyRecSet1 = MyConn.Execute("DELETE FROM Student WHERE ROLLNO=" & CInt(Trim(Text1.Text)) & "")MyConn.CloseMsgBox ("Delete Successfully")Text1.Text = ""Text2.Text = ""End Sub-------------------------------------------------------------------------------------------------------------
Search Here
VB Dynamic Form design
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment