\r\n\r\n
Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > Error 13: Type Mismatch


\r\n \r\n
 
 
Thread Tools Display Modes

\r\n\r\n\r\n
I have a database set up with DAO, the same way the database was created.
\nThe database was not created using this app, but I don\'t believe that this should make any difference.
\nBut the command \'Set rsSet = dbProfile.OpenRecordset(stSQL)\' gets error 13. I don\'t understand where the \'type mismatch\' could even be coming from?
\nAny help, suggestions, etc. would be greatly appreciated.
\n
\r\n
Code:
\r\n
Option Explicit\nOption Compare Text\nPublic wksWorkSpace As Workspace\nPublic dbProfile As Database\nPublic dbStorage As Database\nPublic FSO As FileSystemObject\nPublic stSQL As String\nPublic inType As Integer\n \nPrivate Sub cmdGo_Click()\n Dim rsSet As Recordset\n Dim stLine As String\n \n lstItems.Clear\n If txtSQLAddOn.Text <> "" Then\n Select Case inType\n Case Is < 4\n stSQL = stSQL & " AND " & txtSQLAddOn.Text & " ORDER BY Name"\n Case 4, 5, 6, 9\n stSQL = stSQL & " " & txtSQLAddOn.Text & " ORDER BY Name"\n Case 7\n stSQL = stSQL & " " & txtSQLAddOn.Text & " ORDER BY Index"\n Case 10\n stSQL = stSQL & " " & txtSQLAddOn.Text & " ORDER BY GName"\n End Select\n Else\n Select Case inType\n Case 0, 1, 2, 3, 4, 5, 6, 9\n stSQL = stSQL & " ORDER BY Name"\n Case 7\n stSQL = stSQL & " ORDER BY Index"\n Case 10\n stSQL = stSQL & " ORDER BY GName"\n End Select\n End If\n Set rsSet = dbProfile.OpenRecordset(stSQL) \'This line gives the error\n\n If rsSet.BOF = False Or rsSet.EOF = False Then\n rsSet.MoveFirst\n Do While rsSet.EOF = False\n Select Case inType\n Case 0, 1, 2, 3\n stLine = rsSet!Name & ", " & rsSet!Cost\n If rsSet!UpTo <> "" Then stLine = stLine & ", UpTo(" & rsSet!UpTo & ")"\n If rsSet!Mods <> "" Then stLine = stLine & ", Mods(" & rsSet!Mods & ")"\n If rsSet!Gives <> "" Then stLine = stLine & ", Gives(" & rsSet!Gives & ")"\n If rsSet!Needs <> "" Then stLine = stLine & ", Needs(" & rsSet!Needs & ")"\n If rsSet!Notes <> "" Then stLine = stLine & ", Notes(" & rsSet!Notes & ")"\n If rsSet!Page <> "" Then stLine = stLine & ", Page(" & rsSet!Page & ")"\n Case 4\n stLine = rsSet!Name & ", " & rsSet!Type\n If rsSet!UpTo <> "" Then stLine = stLine & ", UpTo(" & rsSet!UpTo & ")"\n If rsSet!Stat <> "" Then stLine = stLine & ", Stat(" & rsSet!Stat & ")"\n If rsSet!Default <> "" Then stLine = stLine & ", Default(" & rsSet!Default & ")"\n If rsSet!Gives <> "" Then stLine = stLine & ", Gives(" & rsSet!Gives & ")"\n If rsSet!Mods <> "" Then stLine = stLine & ", Mods(" & rsSet!Mods & ")"\n If rsSet!Needs <> "" Then stLine = stLine & ", Needs(" & rsSet!Needs & ")"\n If rsSet!Notes <> "" Then stLine = stLine & ", Notes(" & rsSet!Notes & ")"\n If rsSet!Page <> "" Then stLine = stLine & ", Page(" & rsSet!Page & ")"\n Case 5\n stLine = rsSet!Name & ", " & rsSet!Type\n If rsSet!CastingCost <> "" Then stLine = stLine & ", CastingCost(" & rsSet!CastingCost & ")"\n If rsSet!Needs <> "" Then stLine = stLine & ", Needs(" & rsSet!Needs & ")"\n If rsSet!Duration <> "" Then stLine = stLine & ", Duration(" & rsSet!Duration & ")"\n If rsSet!Time <> "" Then stLine = stLine & ", Time(" & rsSet!Time & ")"\n If rsSet!Notes <> "" Then stLine = stLine & ", Notes(" & rsSet!Notes & ")"\n If rsSet!Page <> "" Then stLine = stLine & ", Page(" & rsSet!Page & ")"\n Case 6\n stLine = rsSet!Name\n If rsSet!Description <> "" Then stLine = stLine & ", Description(" & rsSet!Description & ")"\n stLine = stLine & ", Race(" & rsSet!Race & ")"\n stLine = stLine & ", New(" & rsSet!New & ")"\n Case 7\n stLine = "If " & rsSet!Stat & rsSet!Test & rsSet!Score & " Then " & rsSet!Bonus & " " & rsSet!ApSec & ":" & rsSet!ApName\n Case 9\n stLine = rsSet!Name\n If rsSet!BaseValue <> "" Then stLine = stLine & ", BaseValue(" & rsSet!BaseValue & ")"\n If rsSet!Step <> "" Then stLine = stLine & ", Step(" & rsSet!Step & ")"\n If rsSet!Down <> "" Then stLine = stLine & ", Down(" & rsSet!Down & ")"\n If rsSet!MinScore <> "" Then stLine = stLine & ", MinScore(" & rsSet!MinScore & ")"\n If rsSet!Up <> "" Then stLine = stLine & ", Up(" & rsSet!Up & ")"\n If rsSet!MaxScore <> "" Then stLine = stLine & ", MaxScore(" & rsSet!MaxScore & ")"\n stLine = stLine & ", Round(" & rsSet!Round & ")"\n If rsSet!Symbol <> "" Then stLine = stLine & ", Symbol(" & rsSet!Symbol & ")"\n stLine = stLine & ", Display(" & rsSet!Display & ")"\n If rsSet!DoubleInPlay <> "" Then stLine = stLine & ", DoubleInPlay(" & rsSet!DoubleInPlay & ")"\n Case 10\n stLine = "GroupName(" & rsSet!GName & "), " & rsSet!Tag & ":" & rsSet!Subject\n End Select\n lstItems.AddItem stLine\n rsSet.MoveNext\n Loop\n End If\nEnd Sub\n \nPrivate Sub Form_Load()\n Dim tblDef As TableDef\n Dim Indx As Index\n Dim relMakRel As Relation\n stSQL = "SELECT * FROM ADPQ WHERE Section = \'ADS\'"\n Set FSO = CreateObject("Scripting.FileSystemObject")\n Set wksWorkSpace = CreateWorkspace("", "admin", "", dbUseJet)\n Set dbProfile = wksWorkSpace.OpenDatabase(App.Path & "\\profile.mdb", True, False)\n If FSO.FileExists(App.Path & "\\storage.mdb") Then\n Set dbStorage = wksWorkSpace.OpenDatabase(App.Path & "\\storage.mdb", True, False)\n Else\n Set dbStorage = wksWorkSpace.CreateDatabase(App.Path & "\\storage.mdb", dbLangGeneral)\n \'Table Replace\n\n Set tblDef = dbStorage.CreateTableDef("Replace")\n With tblDef\n .Fields.Append .CreateField("Type", dbText, 10)\n .Fields.Append .CreateField("DelName", dbMemo)\n Set Indx = .CreateIndex("RepIndx")\n Indx.Fields.Append Indx.CreateField("DelName", dbMemo)\n Indx.Unique = True\n Indx.Primary = True\n tblDef.Indexes.Append Indx\n End With\n dbStorage.TableDefs.Append tblDef\n \'Table With\n\n Set tblDef = dbStorage.CreateTableDef("With")\n With tblDef\n .Fields.Append .CreateField("Index", dbLong)\n .Fields("Index").Attributes = dbAutoIncrField\n .Fields.Append .CreateField("DelName", dbMemo)\n .Fields.Append .CreateField("AddName", dbMemo)\n Set Indx = .CreateIndex("WithIndx")\n Indx.Fields.Append Indx.CreateField("DelName", dbMemo)\n Indx.Fields.Append Indx.CreateField("AddName", dbMemo)\n Indx.Unique = True\n Indx.Primary = True\n tblDef.Indexes.Append Indx\n End With\n dbStorage.TableDefs.Append tblDef\n Set relMakRel = dbStorage.CreateRelation("ReplaceToWith", "Replace", "With", dbRelationDeleteCascade)\n relMakRel.Fields.Append relMakRel.CreateField("DelName", dbMemo)\n relMakRel.Fields!DelName.ForeignName = "DelName"\n dbStorage.Relations.Append relMakRel\n \'Next Table\n \n dbStorage.Close\n Set dbStorage = wksWorkSpace.OpenDatabase(App.Path & "\\storage.mdb", True, False)\n End If\nEnd Sub\n \nPrivate Sub optType_Click(Index As Integer)\n Select Case Index\n Case Is < 4\n stSQL = "SELECT * FROM ADPQ WHERE Section = \'" & optType(Index).Caption & "\'"\n Case Else\n stSQL = "SELECT * FROM " & optType(Index).Caption\n End Select\n txtSQLAddOn.Text = ""\n inType = Index\nEnd Sub
\r\n
\r\n \r\n\r\n
\r\n \r\n\r\n \r\n \r\n\r\n \r\n \r\n
\r\n __________________
\r\n Par Midling
\r\n[Insert something really cool here]\r\n
\r\n \r\n \r\n\r\n \r\n\r\n \r\n\r\n
\r\n \r\n \r\n \r\n \r\n Reply With Quote\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n \r\n\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n\r\n\r\n\r\n\r\n'; pd[699241] = '\r\n\r\n \r\n\r\n
\r\n
\r\n
\r\n\r\n
\r\n \r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n \r\n
\r\n
\r\n  \r\n #2  \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n
\r\n \r\n Old\r\n \r\n 03-28-2004, 02:42 AM\r\n \r\n \r\n \r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n
\r\n \r\n Shurik12\r\n Shurik12 is offline\r\n\r\n\r\n
Prev Previous Post   Next Post Next
  #1  
Old 03-27-2004, 07:19 PM
Par Midling Par Midling is offline
Centurion
 
Join Date: Jan 2004
Location: Arkansas
Posts: 139
Default Error 13: Type Mismatch


I have a database set up with DAO, the same way the database was created.
The database was not created using this app, but I don't believe that this should make any difference.
But the command 'Set rsSet = dbProfile.OpenRecordset(stSQL)' gets error 13. I don't understand where the 'type mismatch' could even be coming from?
Any help, suggestions, etc. would be greatly appreciated.
Code:
Option Explicit Option Compare Text Public wksWorkSpace As Workspace Public dbProfile As Database Public dbStorage As Database Public FSO As FileSystemObject Public stSQL As String Public inType As Integer Private Sub cmdGo_Click() Dim rsSet As Recordset Dim stLine As String lstItems.Clear If txtSQLAddOn.Text <> "" Then Select Case inType Case Is < 4 stSQL = stSQL & " AND " & txtSQLAddOn.Text & " ORDER BY Name" Case 4, 5, 6, 9 stSQL = stSQL & " " & txtSQLAddOn.Text & " ORDER BY Name" Case 7 stSQL = stSQL & " " & txtSQLAddOn.Text & " ORDER BY Index" Case 10 stSQL = stSQL & " " & txtSQLAddOn.Text & " ORDER BY GName" End Select Else Select Case inType Case 0, 1, 2, 3, 4, 5, 6, 9 stSQL = stSQL & " ORDER BY Name" Case 7 stSQL = stSQL & " ORDER BY Index" Case 10 stSQL = stSQL & " ORDER BY GName" End Select End If Set rsSet = dbProfile.OpenRecordset(stSQL) 'This line gives the error If rsSet.BOF = False Or rsSet.EOF = False Then rsSet.MoveFirst Do While rsSet.EOF = False Select Case inType Case 0, 1, 2, 3 stLine = rsSet!Name & ", " & rsSet!Cost If rsSet!UpTo <> "" Then stLine = stLine & ", UpTo(" & rsSet!UpTo & ")" If rsSet!Mods <> "" Then stLine = stLine & ", Mods(" & rsSet!Mods & ")" If rsSet!Gives <> "" Then stLine = stLine & ", Gives(" & rsSet!Gives & ")" If rsSet!Needs <> "" Then stLine = stLine & ", Needs(" & rsSet!Needs & ")" If rsSet!Notes <> "" Then stLine = stLine & ", Notes(" & rsSet!Notes & ")" If rsSet!Page <> "" Then stLine = stLine & ", Page(" & rsSet!Page & ")" Case 4 stLine = rsSet!Name & ", " & rsSet!Type If rsSet!UpTo <> "" Then stLine = stLine & ", UpTo(" & rsSet!UpTo & ")" If rsSet!Stat <> "" Then stLine = stLine & ", Stat(" & rsSet!Stat & ")" If rsSet!Default <> "" Then stLine = stLine & ", Default(" & rsSet!Default & ")" If rsSet!Gives <> "" Then stLine = stLine & ", Gives(" & rsSet!Gives & ")" If rsSet!Mods <> "" Then stLine = stLine & ", Mods(" & rsSet!Mods & ")" If rsSet!Needs <> "" Then stLine = stLine & ", Needs(" & rsSet!Needs & ")" If rsSet!Notes <> "" Then stLine = stLine & ", Notes(" & rsSet!Notes & ")" If rsSet!Page <> "" Then stLine = stLine & ", Page(" & rsSet!Page & ")" Case 5 stLine = rsSet!Name & ", " & rsSet!Type If rsSet!CastingCost <> "" Then stLine = stLine & ", CastingCost(" & rsSet!CastingCost & ")" If rsSet!Needs <> "" Then stLine = stLine & ", Needs(" & rsSet!Needs & ")" If rsSet!Duration <> "" Then stLine = stLine & ", Duration(" & rsSet!Duration & ")" If rsSet!Time <> "" Then stLine = stLine & ", Time(" & rsSet!Time & ")" If rsSet!Notes <> "" Then stLine = stLine & ", Notes(" & rsSet!Notes & ")" If rsSet!Page <> "" Then stLine = stLine & ", Page(" & rsSet!Page & ")" Case 6 stLine = rsSet!Name If rsSet!Description <> "" Then stLine = stLine & ", Description(" & rsSet!Description & ")" stLine = stLine & ", Race(" & rsSet!Race & ")" stLine = stLine & ", New(" & rsSet!New & ")" Case 7 stLine = "If " & rsSet!Stat & rsSet!Test & rsSet!Score & " Then " & rsSet!Bonus & " " & rsSet!ApSec & ":" & rsSet!ApName Case 9 stLine = rsSet!Name If rsSet!BaseValue <> "" Then stLine = stLine & ", BaseValue(" & rsSet!BaseValue & ")" If rsSet!Step <> "" Then stLine = stLine & ", Step(" & rsSet!Step & ")" If rsSet!Down <> "" Then stLine = stLine & ", Down(" & rsSet!Down & ")" If rsSet!MinScore <> "" Then stLine = stLine & ", MinScore(" & rsSet!MinScore & ")" If rsSet!Up <> "" Then stLine = stLine & ", Up(" & rsSet!Up & ")" If rsSet!MaxScore <> "" Then stLine = stLine & ", MaxScore(" & rsSet!MaxScore & ")" stLine = stLine & ", Round(" & rsSet!Round & ")" If rsSet!Symbol <> "" Then stLine = stLine & ", Symbol(" & rsSet!Symbol & ")" stLine = stLine & ", Display(" & rsSet!Display & ")" If rsSet!DoubleInPlay <> "" Then stLine = stLine & ", DoubleInPlay(" & rsSet!DoubleInPlay & ")" Case 10 stLine = "GroupName(" & rsSet!GName & "), " & rsSet!Tag & ":" & rsSet!Subject End Select lstItems.AddItem stLine rsSet.MoveNext Loop End If End Sub Private Sub Form_Load() Dim tblDef As TableDef Dim Indx As Index Dim relMakRel As Relation stSQL = "SELECT * FROM ADPQ WHERE Section = 'ADS'" Set FSO = CreateObject("Scripting.FileSystemObject") Set wksWorkSpace = CreateWorkspace("", "admin", "", dbUseJet) Set dbProfile = wksWorkSpace.OpenDatabase(App.Path & "\profile.mdb", True, False) If FSO.FileExists(App.Path & "\storage.mdb") Then Set dbStorage = wksWorkSpace.OpenDatabase(App.Path & "\storage.mdb", True, False) Else Set dbStorage = wksWorkSpace.CreateDatabase(App.Path & "\storage.mdb", dbLangGeneral) 'Table Replace Set tblDef = dbStorage.CreateTableDef("Replace") With tblDef .Fields.Append .CreateField("Type", dbText, 10) .Fields.Append .CreateField("DelName", dbMemo) Set Indx = .CreateIndex("RepIndx") Indx.Fields.Append Indx.CreateField("DelName", dbMemo) Indx.Unique = True Indx.Primary = True tblDef.Indexes.Append Indx End With dbStorage.TableDefs.Append tblDef 'Table With Set tblDef = dbStorage.CreateTableDef("With") With tblDef .Fields.Append .CreateField("Index", dbLong) .Fields("Index").Attributes = dbAutoIncrField .Fields.Append .CreateField("DelName", dbMemo) .Fields.Append .CreateField("AddName", dbMemo) Set Indx = .CreateIndex("WithIndx") Indx.Fields.Append Indx.CreateField("DelName", dbMemo) Indx.Fields.Append Indx.CreateField("AddName", dbMemo) Indx.Unique = True Indx.Primary = True tblDef.Indexes.Append Indx End With dbStorage.TableDefs.Append tblDef Set relMakRel = dbStorage.CreateRelation("ReplaceToWith", "Replace", "With", dbRelationDeleteCascade) relMakRel.Fields.Append relMakRel.CreateField("DelName", dbMemo) relMakRel.Fields!DelName.ForeignName = "DelName" dbStorage.Relations.Append relMakRel 'Next Table dbStorage.Close Set dbStorage = wksWorkSpace.OpenDatabase(App.Path & "\storage.mdb", True, False) End If End Sub Private Sub optType_Click(Index As Integer) Select Case Index Case Is < 4 stSQL = "SELECT * FROM ADPQ WHERE Section = '" & optType(Index).Caption & "'" Case Else stSQL = "SELECT * FROM " & optType(Index).Caption End Select txtSQLAddOn.Text = "" inType = Index End Sub
__________________
Par Midling
[Insert something really cool here]
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Type Mismatch in criteria expression!!! marycore Database and Reporting 2 03-17-2003 04:06 AM
Type Mismatch??? AndrewMac44 DirectX 2 03-13-2003 11:07 AM
Data type mismatch?? krilleric Database and Reporting 13 03-09-2003 12:49 PM
A type mismatch Trisha General 2 03-06-2003 08:57 PM
Type Mismatch error gskahlon79 Miscellaneous Languages 3 02-18-2003 07:59 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->