|
-
November 20th, 1999, 01:32 AM
#1
SQL Question
I am writing a program using a MS Office Database and a visual basics program to run it. What I am trying to do is to have the students write in the name of a student that they want, and have the program post the E mail name for that student. The name of the database is "student" the field that I am searching is called "Name", and the code that I am trying to use looks like:
Data1.RecordSource = "Select * from students where Name = txtname.text "
Data1.Refresh
txtname.text is the text box where I want the students to write the name of the student that they are looking for. If you can help it would be greatly appriciated. Thanks.
-
November 20th, 1999, 08:33 AM
#2
Re: SQL Question
Replace with this:
Data1.RecordSource = "Select * from students where Name = " & txtname.text
Vlad
-
November 20th, 1999, 09:05 AM
#3
Re: SQL Question
If it's a text field, you'll likely have to enclose the field value with single quotes:
Data1.RecordSource = "Select * from students where Name = '" & txtname.text & "'"
Good luck,
Mike
-
November 20th, 1999, 10:01 AM
#4
Re: SQL Question
Hi,
Change the statement -
"Select * from students where Name = txtname.text "
to
"Select * from students where Name = '" & txtname.text & "'"
good luck :-)
Santulan
-
November 20th, 1999, 11:28 AM
#5
Re: SQL Question
Thanks for the help, it worked great!
-
November 22nd, 1999, 03:32 PM
#6
Re: SQL Question
If you are going to do it this way, you should be aware that names with an apostrophe in them like O'hara will cause a runtime error (the single apostrophe tells the database that you have ended the text field). Move the text to a VB string and then replace all instances of apostrophe with two apostrophe. This will tell the SQL engine that you are selecting/updating/inserting/deleting a text object with an single apostrophe.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|