Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
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  
Old May 24th, 2004, 09:35 PM
Matt71 Matt71 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 21 Matt71 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Return Value of Function

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

Reply With Quote
  #2  
Old May 24th, 2004, 10:43 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,751 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 3 h 32 m 46 sec
Reputation Power: 443
The function is actually calling another function (ExecuteSql).
Code:
Set TCList1 = ExecuteSQL(rs, MsgText)

Set callSQL = TCList1

Reply With Quote
  #3  
Old May 25th, 2004, 12:18 AM
Matt71 Matt71 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 21 Matt71 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Type Mismatch

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???

Reply With Quote
  #4  
Old May 25th, 2004, 11:11 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 19 h 31 m 41 sec
Reputation Power: 180
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

Reply With Quote
  #5  
Old May 30th, 2004, 01:03 PM
Beer Beer is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 1 Beer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Lightbulb

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.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Return Value of Function


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway