|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
I am trying to fix a program that was made by some other people, so as to get it to work on our network settings.
A problem that I am running in to is when passing a string parameter to a function, I keep coming up with a Type Mismatch error. My question is: If you have set a function to return a value, in this case a recordset, when calling the function do you have to assign it to a variable? The way that I see it below, is that the function is being called but the value being returned isn't being assigned anywhere. The code is as follows: txtSQL = "INSERT INTO TC (TC_ID, Active, Surname, Firstname) VALUES('" & id & "',0, '" & sName & "', '" & fName & "');" callSQL (txtSQL) Public Function callSQL(rs As String) As ADODB.Recordset Dim TCList1 As ADODB.Recordset Dim MsgText As String MsgBox "In CallSQL function: SQL Statement = " & vbCrLf & rs Set TCList1 = ExecuteSQL(rs, MsgText) Set callSQL = TCList1 End Function |
|
#2
|
||||
|
||||
|
The function is actually calling another function (ExecuteSql).
Code:
Set TCList1 = ExecuteSQL(rs, MsgText) Set callSQL = TCList1 |
|
#3
|
|||
|
|||
|
I hadn't noticed that before. However I actually receive an error at the call of the first function. I have a msgbox as the first line of code in that CallSQL function to see if it gets in to it, but it doesn't. Can you see anything wrong with the syntax??
The fields in the database that it's talking about inserting into are TC_ID, FirstName, Surname and Active, which are the following data types: TC_ID - Unsigned Int Firstname, Surname - Varchar Active - Either a yes/no field or Int. I could fix the problem if it was to do with putting the wrong type of value into a field, but it doesn't seem to even get that far. Any ideas??? |
|
#4
|
|||
|
|||
|
As a guess, try removing the trailing ;
Also maybe send txtSql to a msgbox before you execute it, and see what the final sql looks like.
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#5
|
|||
|
|||
|
From what I can see the problem is here:
txtSQL = "INSERT INTO TC (TC_ID, Active, Surname, Firstname) VALUES('" & id & "',0, '" & sName & "', '" & fName & "');" callSQL (txtSQL) this should be: dim ReturnRS as adodb.recordset txtSQL = "INSERT INTO TC (TC_ID, Active, Surname, Firstname) VALUES('" & id & "',0, '" & sName & "', '" & fName & "');" set ReturnRS = callSQL(txtSQL) Don't forget to set ReturnRS = Nothing when you reach the end of this routine. |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Return Value of Function |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|