Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 24th, 2006, 03:34 AM
Registered User
 
Join Date: Jul 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ghian72
Default ASP-SQL Server Type Mismatched Error

Hello everybody. Is there anyone who can help to solve my problem regarding Type-Mismatched Error. I've created a login script using ASP connecting to SQL Server 2000 Database. The error appears when I assigned recordset values to session.

<%
  dim rsTemp

  nLastName = trim(request("lname"))
  nFirstName = trim(request("fname"))
  nMidName = trim(request("mname"))
  nPword = Trim(request("pword"))

pSQLServerConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=memkeeper;Data Source=(local);"

'*** CHECK USERNAME FROM MAIN LIST AND GENERATE DATABASE FILENAME FROM ACCOUNT NUMBER ****************

mySQL = "SELECT tblAcct.LastName, tblAcct.MidName, tblAcct.FirstName FROM tblAcct WHERE (((tblAcct.LastName)='" & nLastName & "') AND ((tblAcct.FirstName)='" & nFirstName & "') AND ((tblAcct.MidName)='" & nMidName & "') AND ((tblAcct.Password)='" & nPword & "'));"

  set connSql = server.createObject("adodb.connection")
  connSql.Open(pSQLServerConnectionString)
  set rsTemp = server.createObject("adodb.recordset")

  rsTemp.lockType = adLockOptimistic
  rsTemp.cursorType = adOpenStatic
  rsTemp.cursorLocation = adUseClient
  rsTemp.open mySQL, connSql

  if rstemp.eof then
    cMsg = "Your authentication data is incorrect."
    response.redirect "message.asp?message=" & Server.Urlencode(cMsg)
  end if

  set rsTemp = nothing
  set connSql = nothing

  session("islogged") = 1
  session("fName") = rsTemp("FirstName") '<- The error appears here.
  session("mName") = rsTemp("MidName")
  session("lName") = rsTemp("LastName")
  session("acctName") = rsTemp("LastName") & ", " & rsTemp

  response.redirect "main.asp"
%>

 
Old July 24th, 2006, 05:56 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii ghian72!!
session("fName") = rsTemp("FirstName")
>>>Check for the rsTemp("FirstName")
probably rsTemp("FirstName") returns null or empty
>>>solution 1:to avoid such error plz check before assignment
i.e do like
if(isNull(rsTemp("FirstName"))) then
session("fName") = " "
else
 session("fName") = rsTemp("FirstName")
end if

>>>solution 2:you can also get null string(i.e '') with sql query using
select isnull(FirstName,'') as FirstName from mytable

Hope this will help you





Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Type:Server.MapPath(), ASP 0171 (0x80004005) phantom3008 ASP.NET 1.0 and 1.1 Basics 2 April 26th, 2007 02:28 PM
rounding up SqlDbType.Money TYPE in sql server olambe BOOK: ASP.NET Website Programming Problem-Design-Solution 2 December 9th, 2005 04:46 PM
ASP error when connecting to a new SQL server Cinderella Classic ASP Basics 2 June 21st, 2005 10:00 AM
Error in connecting to sql server 2000 using asp method SQL Server 2000 1 March 7th, 2005 11:05 PM
what data type in sql server kiwibey SQL Server 2000 3 November 22nd, 2004 11:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.