TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
David Carter
NA
86
22.6k
Use Variable in query
Aug 24 2010 2:48 AM
I have an OleDbAdapter attached to a datagridview.
I wish to take the value in a textbox to use in a query to fill the datagridview.
Eg. The following works: David Carter in this instance is typed into the Query as a constant.
OleDbDataAdapter1.SelectCommand.CommandText =
"Select * From InfringementRecords Where([INFStudent] = 'David Carter')"
But I don't want David Carter to be fixed in the query, I want to use a variable as entered into a textbox
Dim SelectName as string
SelectName = Textbox1.text
OleDbDataAdapter1.SelectCommand.CommandText =
"Select * From InfringementRecords Where([INFStudent] =
"
& SelectName &
")"
That gives me an error:
Syntax error (missing operator) in query expression '([INFStudent] = David Carter)'.
Does anyone know how to use a variable in a query?
Visual Studio 2008.
Regards,
David
Reply
Answers (
4
)
xmltextreader does not release a file
TreeView Check Box population