English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

This is our project at school. We are going to create a program wherein the VB is linked in a SQL database, meaning; the VB as our front-end and SQL is our backend. So, if the user asks an info, let's say he just want to view the list of students taking the IT course. Then, the program will retrive the data to the SQL database, and view it in the VB program again.

Please help me with this. I don't really have any idea on this one so hope you guys will share your sheer talents in programming Lol.

Thanks a lot

2007-01-15 17:14:57 · 4 answers · asked by bill 2 in Computers & Internet Programming & Design

4 answers

Look up "ActiveX Data Objects" in the help file for your VB environment.

2007-01-16 10:05:19 · answer #1 · answered by Richard H 7 · 0 0

Here is some useful code for ya..hope it helps:

Dim conn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rs As ADODB.Recordset
Dim sConnString As String
Dim iCtr As Integer

'MAKE SURE YOU HAVE LATEST VERSION OF
'OLE DB PROVIDERS, WHICH YOU CAN GET AT
'http://www.microsoft.com/data

'BE SURE TO INCLUDE A REFERENCE TO MICROSOFT
'ACTIVE X DATA OBJECTS IN YOUR PROJECT

' IF SQL SERVER USE SOMETHING LIKE THIS
'Data Source = Server Name
'Initial Catalog = Database
'Use your own user names and password

sConnString = "Provider=SQLOLEDB.1;User ID=sa;password=mypassword;Initial Catalog=MyDatabase;Data Source = MySQLServer;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096"

'IN ACCESS USE SOMETHING LIKE THIS:
'Change Data Source to full path of database
sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyDatabase.mdb"


conn.Open sConnString
Set cmd.ActiveConnection = conn

'REPLACE MYTABLE WITH YOUR OWN TABLE
cmd.CommandText = "SELECT * FROM MYTABLE"
cmd.CommandType = adCmdText
Set rs = cmd.execute

Do While Not rs.EOF
For iCtr = 0 To rs.fields.Count - 1
'OutPuts Name and Value of each field
Debug.Print rs.Fields(iCtr).Name & ": " & _
rs.Fields(iCtr).Value
Next
rs.MoveNext
Loop
Set rs = Nothing
Set cmd = Nothing
conn.Close
Set conn = Nothing

2007-01-15 17:26:33 · answer #2 · answered by Anonymous · 0 0

From the toolbox, drag a SqlDataSource onto your form. Then click on the SqlDataSource and click on the sensible Tag then click Configure concepts source. The wizard will take you in the time of a few thing.

2016-11-24 20:37:32 · answer #3 · answered by Anonymous · 0 0

Lots of different ways...

Read this: http://msdn2.microsoft.com/en-us/vbasic/ms789183.aspx

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/newdtastvs05.asp

2007-01-15 17:22:52 · answer #4 · answered by Anonymous · 0 0

fedest.com, questions and answers