I am trying to make project for final year of graduation. As per the golden rules of software development, I have created my database and set the primary key, and also set the foreign keys, User name and password.
In short I have created the whole database with each and every requirement. Now the problem arises that I am unable to connect to database. The code through which I am trying to connect is given below.
Dim dbconn As ADODB.Connection
Dim dbrs As ADODB.Recordset
Dim sqlstr As String
Public Sub Form1_Load()
Set Connect = CreateObject("ADODB.Connection")
Connect.ConnectionString = "DSN=Xcellent Garment;UID=;PWD=;"
Connect.Open
Call combolist
End Sub
Public Sub combolist()
'open database connection
dbconn.Open ("DSN=Xcellent Garment")
'customer
sqlstr = "select * from Customer"
dbrs.Open (sqlstr)
If dbrs.RecordCount >= 1 Then
dbrs.MoveFirst
While Not dbrs.EOF
Me.Combo1.AddItem (dbrs("CName").Value)
'Me.Combo1.List (dbrs("CName").Value)
dbrs.Move (1)
Wend
End If
Combo1.Index = 1
If dbrs.State = 1 Then
dbrs.Close
dbconn.Close
End Sub
If anybody can find solution for this problem please reply.
Bookmarks