Microsoft KB Archive/105171

= PRB: Error 13 (Type Mismatch) & Error 3061 w/ SQL Queries =

Article ID: 105171

Article Last Modified on 1/8/2003

-

APPLIES TO


 * Microsoft Visual Basic 3.0 Professional Edition

-



This article was previously published under Q105171



SYMPTOMS
Incorrect SQL syntax can cause either of the following error messages:


 * Type Mismatch (Error 13)
 * 1 parameter expected but only 0 were supplied (Error 3061)

You may receive one of the above errors with a data access object method that contains a SQL statement, or when using the Refresh method on a Data control that has its RecordSource property set to a SQL statement.



CAUSE
The SQL syntax is incorrect.



RESOLUTION
Correct the SQL syntax. See the examples in the Steps to Reproduce Behavior section below.



Steps to Reproduce Behavior
 Start a new project in Visual Basic. Form1 is created by default. Add a data control (Data1) and two command buttons (Command1 and Command2) to Form1.  Set the following properties for the Data1 control:   Control           Property           Value Set --  Data1             DataBaseName       C:\VB\BIBLIO.MDB Data1            RecordSource       Authors

  Add the following code to the Command1 Click event procedure: Sub Command1_Click data1.RecordSource = "Select * from authors where author = 4" data1.Refresh       ' This gives the type mismatch error End Sub

NOTE: If you change the SQL query to the following, you will receive the 3061 error (1 parameter expected but only 0 were supplied): data1.RecordSource = "Select * from authors where author = brown"

The following query corrects the SQL syntax. It should work correctly without giving an error: data1.RecordSource = "Select * from authors where author = 'brown'"

  Add the following code to the Command2 Click event procedure: Sub Command2_Click Dim db As database Dim ds As dynaset Set db = OpenDatabase("C:\VB\BIBLIO.MDB") sqlquery1$ = "Select * from authors where author = 4" Set ds = db.CreateDynaset(sqlquery1$) 'Gives type mismatch error End Sub

NOTE: If you change the SQL query to the following, you will receive the 3061 error (1 parameter expected but only 0 were supplied): sqlquery1$ = "Select * from authors where author = brown"

The following query corrects the SQL syntax. It should work correctly without giving an error: sqlquery1$ = "Select * from authors where author = 'brown'"

</li> From the Run menu, choose Start (ALT, R, S) or press the F5 key to run the program. Click the Command1 button to get the error. Then restart the program, and click the Command2 button to get the error.</li></ol>

Additional query words: 3.00

Keywords: kbprb KB105171

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.