Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type mismatch CLng 1

Status
Not open for further replies.

nonprogrammer

Technical User
Dec 28, 2005
143
US
Hi,

I get the following error


Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'CLng'
/aqpc/wb/updateform.asp, line 12


everything was working well and then all of the sudden it stop working.
here is what my code looks like
Code:
<%


'Dimension variables
Dim adoCon 			'Holds the Database Connection Object
Dim rsiddb			'Holds the recordset for the record to be updated
Dim strSQL			'Holds the SQL query for the database
Dim lngRecordNo			'Holds the record number to be updated

'Read in the record number to be updated
lngRecordNo = CLng(Request.QueryString("ID"))

'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("form.mdb")

'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=iddb"

'Create an ADO recordset object
Set rsGuestbook = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT userstable.* FROM aq WHERE ID=" & lngRecordNo

'Open the recordset with the SQL query 
rsiddb.Open strSQL, adoCon
%>

help please
 
In page call (updateform.asp?ID=???&....), ??? is obviously not an integer.

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
I created a link that passes the variable

Code:
ID # </font></strong> 
        <%Response.Write ("<a href=""updateform.asp?id="">")
		Response.Write (rsGuestbook("id"))
		Response.Write ("</a>")%>
      </div></td>
 
If you're using the following code to get the rsGuestbook("id"), then you need to figure out why you're using rsiddb instead. The part in red should be rsGuestbook.
Code:
'Create an ADO recordset object
Set rsGuestbook = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT userstable.* FROM aq WHERE ID=" & lngRecordNo

'Open the recordset with the SQL query 
[COLOR=red]rsiddb[/color].Open strSQL, adoCon

------------------------------------------------------------------------------------------------------------------------
"I am not young enough to know everything."
Oscar Wilde (1854-1900)
 
I am sorry I copied the wrong code the rsGuestbook I found in this forum of somebody that was asking about checkboxes. I kind of had the same problem but I figured it out. But some of the code that rv41 posted was useful to me so I modified to fit into my application. So that is where the rsGuestbook is from. It is
Code:
rsiddb.Open and Set rsiddb = Server.CreateObject("ADODB.Recordset")

Ok so here is what I am trying to accomplish.
I have a page called quick view that is where the users can see their records. I call this page view1. If they click on a link they go to that specific record (so far everything works fine.) if I put a link in view1 to go and edit the record; that is when I run into trouble and I get the
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'CLng'
/aqpc/wb/updateform.asp, line 12 error

But If I put the quick view page link to go to the edit page there is no trouble. Only when I try to go from the view1 to the edit is when I have trouble

view1 looks like this
Code:
 Project # </font></strong> 
        <%Response.Write ("<a href=""edit.asp?id="">")
		Response.Write (rsiddb("id"))
		Response.Write ("</a>")%>
this is where i create the link to go to the edit page


the edit page looks like this
Code:
<%


'Dimension variables
Dim adoCon 			'Holds the Database Connection Object
Dim rsiddb			'Holds the recordset for the record to be updated
Dim strSQL			'Holds the SQL query for the database
Dim lngRecordNo			'Holds the record number to be updated
'Read in the record number to be updated
lngRecordNo =CLng(Request.QueryString("ID"))

'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("aqform.mdb")

'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=guestbook"

'Create an ADO recordset object
Set rsiddb = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT aq.* FROM aq WHERE ID=" & lngRecordNo

'Open the recordset with the SQL query 
rsiddb.Open strSQL, adoCon
%>
 
Ok, I think I see your problem. It is in this code here:
Code:
Project # </font></strong> 
        <%Response.Write ("<a href=""edit.asp?id="">")
        Response.Write (rsiddb("id"))
        Response.Write ("</a>")%>
You are not actually assigning a value to the id in the querystring. If it is your intention to give it a value, then you need to change it as follows:
Code:
Project # </font></strong> 
        <%Response.Write ("<a href=""edit.asp?id=""")
        Response.Write (rsiddb("id"))
        Response.Write ("[COLOR=red]>[/color]</a>")%>

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
Chopstik, If I try your code then my link does not show in the page
 
Ok, let me try this again. You're going to have to use your rsiddb("id") twice in your code. Like this:
Code:
Project # </font></strong> 
        <%Response.Write ("<a href=""edit.asp?id=""")
        Response.Write (rsiddb("id"))
        Response.Write (">[COLOR=red]" & rsiddb("id") & "[/color]</a>")%>
This should now both show your link (or anchor tag) along with the value for the id that will be part of your querystring. Do you see what was missing originally? You were only using the rsiddb("id") to list as your visual anchor, but not as the value of the querystring id.

Or maybe I'm just sounding confusing... Either way, the code should do as you want now...

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
in the code provided by Chopstik...remove the part that i striked out...

Code:
Project # </font></strong> 
        <%Response.Write ("<a href=""edit.asp?id=""")
[s]        Response.Write (rsiddb("id"))[/s]
        Response.Write (">" & rsiddb("id") & "</a>")%>

also try this:

Code:
Project # </font></strong> 
        <%Response.Write ("<a href=""edit.asp?id=""")
        Response.Write (">" & rsiddb("id")</a>")%>

-DNG
 
DNG,

Sorry, but your code simply re-creates the original problem that (s)he was having. (S)he is not passing the rsiddb("id") back to the querystring of the next page with your code and thus will reproduce the original error with the cLng because there is no value for the querystring ID. I believe (s)he will need to use the last version of the code that I posted in order to be able to get past the original problem.

:)

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
oops...sorry...i realized after posting...lets see if the OP gets it sorted...

-DNG
 
I got it guys I did this
Code:
<a href="updateform.asp?id=<% = rsiddb("id") %>"><% = rsiddb("id") %></a>
This seems to work. I wish I could take credit for this but I acutally found it in here


Thank you Chopstik and thank you DotNetGnat
This is acutally my frist post in here. I really like this forum.
 
I'm glad you were able to find the answer you needed. And if you really like this forum, then as you continue to learn more, pass your knowledge onto others. It is a give and take society and the more you give, the more you learn. Good luck!
[thumbsup]

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
Since I seem to be responding to a lot of closed posts today, here is a working version of Chopstiks correction to the original post:
Code:
[u]Before:[/u]
Project # </font></strong>
        <%Response.Write ("<a href=""edit.asp?id=[highlight]""[/highlight]")
        Response.Write (rsiddb("id"))
        Response.Write (">" & rsiddb("id") & "</a>")%>

[u]After[/u]
Project # </font></strong>
        <%Response.Write ("<a href=""edit.asp?id=")
        Response.Write (rsiddb("id"))
        Response.Write ("[highlight]""[/highlight]>" & rsiddb("id") & "</a>")%>

barcode_1.gif
 
<blush>
Thanks for the correction, Tarwn.
</blush>

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top