|
-
May 29th, 2005, 07:58 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Databse Problem...
I am tryin to create a form for my database in vb6.
the tables were made in access and saved to the harddrive
i add a data control to the form and set the DatabaseName to the access database i have created...
i then try to set the RecordSource to a table in the database, however when i click on the drop down arrow to select the table ann error message comes up stating that a '.mdb' is an unrecognised database format????
any help would be greatly appreciated
GTJ
-
May 29th, 2005, 09:22 AM
#2
Re: Databse Problem...
what version of access?
and what is the control using to connect, ADO or DAO?
pete
-
May 29th, 2005, 10:50 AM
#3
Thread Starter
Hyperactive Member
Re: Databse Problem...
Access 2000 and what is ADO or DAO?
-
May 29th, 2005, 12:26 PM
#4
Re: Databse Problem...
 Originally Posted by greythej
I am tryin to create a form for my database in vb6.
the tables were made in access and saved to the harddrive
i add a data control to the form and set the DatabaseName to the access database i have created...
i then try to set the RecordSource to a table in the database, however when i click on the drop down arrow to select the table ann error message comes up stating that a '.mdb' is an unrecognised database format????
any help would be greatly appreciated
GTJ
Before you use Bound Controls you should Read This Article entitled "Why Data Binding and the like are evil" (Link courtesy of Hack).
Here is what I use to connect to an Access Database:
VB Code:
Dim cn As adodb.Connection
Dim rs As adodb.Recordset
Dim strSQL As String
Dim a As Single
Dim strConnectString as String
Dim strDBCursorType As String
Dim strDBLockType As String
Dim strDBOptions As String
strDBCursorType = adOpenDynamic 'CursorType
strDBLockType = adLockOptimistic 'LockType
strDBOptions = adCmdText 'Options
Set cn = New adodb.Connection
ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & App.Path & "\[color="#FF0080"][B]YourDatabaseName.mdb[/B][/color]" & _
";Jet OLEDB:Engine Type=5;"
cn.Open ConnectString
With cn
.CommandTimeout = 0
.CursorLocation = adUseClient
End With
Set rs = New adodb.Recordset 'Creates record set
strSQL = "SELECT * "
strSQL = strSQL & "FROM [B][color="#FF0080"]YourTableName[/color][/B];"
rs.Open strSQL, cn, strDBCursorType, strDBLockType, strDBOptions
If rs.RecordCount = 0 Then
MsgBox "No Records"
Else
For a = 1 To rs.RecordCount ' Loops through Recordset
'Put your code here
Me.Text1.Text = [B][color="#FF0080"]rs!FieldName1[/color][/B] & ""
Me.Text2.Text = [B][color="#FF0080"]rs!FieldName2[/color][/B] & ""
'.....
rs.MoveNext
Next a
End If
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
Change the Code in Red to the names of your schema.
Last edited by Mark Gambo; May 29th, 2005 at 12:32 PM.
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
-
May 29th, 2005, 07:32 PM
#5
Hyperactive Member
Re: Databse Problem...
data controll doesn't recognize access 2000 or higher's database, you have to download sp6 and mdac at microsoft
-
May 30th, 2005, 11:00 AM
#6
Thread Starter
Hyperactive Member
Re: Databse Problem...
visual basic sp6 or access sp6?
-
Jun 1st, 2005, 02:13 AM
#7
Hyperactive Member
-
Jun 1st, 2005, 02:20 AM
#8
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|