This is my tutorial on setting up a database...
1.)
Make the following forms:
Form1
Module1
2.)
You also need the following components:
----Microsoft ADO Data Controls 6.0 (OLEDB)
after adding the component, you need to insert that component to the form...
3.)
Type this on your module...
Public rs = new ADODB.Recordset
Public Function cnx() as ADODB.Connection
Set cnx = New ADODB.Connection
cnx.CursorLocation = adUseClient
cnx.Open 'Datasource here...
End Function
4.)
To get the datasource, insert ADODC to your form. Next, click on the build. If you are using MS Access for your database, use Microsoft Jet 4.0 OLE DB Provider and select your database.
Use Microsoft OLE DB Provider for SQL Server if you are using SQL Server..
..then click Ok.
Copy the code in the connection string and paste it on your module in the datasource and do it like this:
cnx.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master"
..with the quotations on.
Well.. that's about it on the connection!. ^_^
5.)
Before we do anything, we need to add a record in the database. Create a table named tblSample and 2 fields for ID and Name.
6.)
Next is we add 2 text boxes in our form. Name them as txtID and txtName.
7.)
Add this code in the form load.
Private Sub Form_Load()
Set rs = new ADODB.Recordset
rs.Open "SELECT * FROM tblSample", cnx, 3, 3
With rs
txtID.Text = !ID
txtName.Text = !Name
End With
End Sub
8.)
Run your program!.. XD
Enjoy! ^_^
1.)
Make the following forms:
Form1
Module1
2.)
You also need the following components:
----Microsoft ADO Data Controls 6.0 (OLEDB)
after adding the component, you need to insert that component to the form...
3.)
Type this on your module...
Public rs = new ADODB.Recordset
Public Function cnx() as ADODB.Connection
Set cnx = New ADODB.Connection
cnx.CursorLocation = adUseClient
cnx.Open 'Datasource here...
End Function
4.)
To get the datasource, insert ADODC to your form. Next, click on the build. If you are using MS Access for your database, use Microsoft Jet 4.0 OLE DB Provider and select your database.
Use Microsoft OLE DB Provider for SQL Server if you are using SQL Server..
..then click Ok.
Copy the code in the connection string and paste it on your module in the datasource and do it like this:
cnx.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master"
..with the quotations on.
Well.. that's about it on the connection!. ^_^
5.)
Before we do anything, we need to add a record in the database. Create a table named tblSample and 2 fields for ID and Name.
6.)
Next is we add 2 text boxes in our form. Name them as txtID and txtName.
7.)
Add this code in the form load.
Private Sub Form_Load()
Set rs = new ADODB.Recordset
rs.Open "SELECT * FROM tblSample", cnx, 3, 3
With rs
txtID.Text = !ID
txtName.Text = !Name
End With
End Sub
8.)
Run your program!.. XD
Enjoy! ^_^