SQL COMMAND PROBLEM?!?!?

databases United States
  • 19 years ago

    I want to find a certain record in my database.  The search Criteria comes from text1  This is what I thought it wuold be:


    select LASTNAME, FIRSTNAME, DOB from dc where LASTNAME = text1.text


    This doesn't work.  Can you please help.

  • 19 years ago

    Here is how it works:


    "SELECT A, B, C FROM Table1 WHERE A = '" & Text1.Text & "'"

  • 19 years ago

    I tried what you said but I couldn't get it to work.  I just got errors this is what I typed in.


    data1.recordsource = "SELECT * FROM Titles WHERE PubID = '" & Text1.Text & "'"


    I wouldn't work. Can you tell me what I'm doing wrong?

  • 19 years ago

    I tried what you said but I couldn't get it to work.  I just got errors this is what I typed in.


    data1.recordsource = "SELECT * FROM Titles WHERE PubID = '" & Text1.Text & "'"


    I wouldn't work. Can you tell me what I'm doing wrong?

  • 19 years ago

    What error are you getting?

  • 19 years ago

    The Error I get is the following: "Data type mismatch in criteria expression."


    Can you help?

  • 19 years ago

    PubID wouldn't happen to be an integer, number or AutoNumber field type?

  • 19 years ago

    Yes its an integer.  Does this make a diffrence?

  • 19 years ago

    Try to remove the single quote...the single quote is for text and date data type.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“If Java had true garbage collection, most programs would delete themselves upon execution.” - Robert Sewell