You are on page 1of 1

Private Sub Command1_Click()

Dim conn As New ADODB.Connection ‘( declaring the object as connection object )


Dim rs As New ADODB.Recordset ‘( declaring the object as recordset object )
Dim strSQL As String
strSQL = “select * from emp"
Set conn = New ADODB.Connection ‘( creating new connection )
conn.Open "Provider=OraOLEDB.Oracle.1;Password=tiger;Persist Security Info=True;User ID=system"
‘(Opening the connection if you are using ORACLE 10g )
rs.CursorType = adOpenStatic
rs.Open strSQL, conn ‘( reading the data from database and store it in a “record set” )
Set DataGrid1.DataSource = rs ‘( sending the that data into data grid )
conn.Execute ("commit") ‘( If we want to execute any SQL command we can use it )
‘conn.Execute ("insert into employees values(seq_no.nextval,'" & Text1.Text & "')")
'oconn.Execute ("create table siva ( frnds varchar2(15))")
oconn.Execute ("commit")
rs.Close
rs.Open strSQL, oconn
Set DataGrid1.DataSource = rs
End Sub

*********

conn.Open "Provider=OraOLEDB.Oracle.1;Password=tiger;Persist Security Info=True;User ID=system"


The red marked string is called connection string. If the above string is not working....
then copy the “connection string” after build the string mentioned in
http://www.johnsmiley.com/cis18/Smiley003.pdf

To add data-grid to the form:


Project  components  Microsoft data grid control 6.0  ok

Reference:
http://www.w3schools.com/ADO/ado_ref_connection.asp
http://support.microsoft.com/kb/308047
http://www.vb-helper.com/howto_ado_insert_into.html
http://www.johnsmiley.com/cis18/Smiley004.pdf

You might also like