Problems with data conversion from SQL ServerDB -

Results 1 to 2 of 2

Thread: Problems with data conversion from SQL ServerDB -

  1. #1
    Join Date
    Dec 1969

    Default Problems with data conversion from SQL ServerDB -

    I have an ASP credit application that on form submits to 4 SQL Server DB tables. The first one goes in no problem to the customers table, automatically generating an autonumber. This autonumber field from the customers table of type INT is to be used and inserted into another table in the second insert. I have created a variable x to hold the select that returns the MAX(custID) FROM Customers.<BR><BR>x = SELECT MAX(custid) FROM Customers<BR><BR>My problem is obvious, when I try and insert the variable into the DB table which is of type INT I get an error - data type mismatch. I have tried CONVERTING and CASTING with no luck. I realize that I am retieving an INT into a STRING, needing to change it into an INT for the INSERT. I am confused, PLEASE HELP...

  2. #2
    Michal M Guest

    Default RE: Problems with data conversion from SQL ServerD

    Hi Jeff,<BR>I think you missed a step here. It looks like you assigned the string value "SELECT MAX(custid) FROM Customers" to the parameter x. What you wanted to do is execute the SQL statement above, and then retrieve the result from a recordset, and use it to construct the next SQL statement:<BR>Here is a rough example of what I think you wanted to do<BR>&#060;%<BR> strSQL = " SELECT MAX(custid) FROM Customers"<BR> Set RS = Conn.Execute (strSQL)<BR> If Not(RS.EOF) Then<BR> x = RS(0)<BR> End If<BR><BR> &#039&#039 Now build next SQL statement using the value in x<BR> strSQL2 = " INSERT INTO Table2 (Id,Name) VALUES (" &_<BR> x & ",&#039Name!!&#039)"<BR>%&#062;<BR><BR>Hope this helps,<BR>Michal M

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts