|
-
Dec 12th, 2002, 02:05 PM
#1
Thread Starter
Member
WHERE (not Santa) clause question..
This block of code is executing perfectly without the WHERE clause inserted at the end of the dim statement; yet when it's there, the datagrid doesn't fill in and appear. Any ideas?
Thanks much....Troy
Private Sub btnGI_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGI.Click
Select Case ddlF002.SelectedIndex()
Case 0
Dim myQuery As String = "SELECT * FROM [tbl * F002 > 4 J] WHERE MUFLID =" & Chr(39) & ddlWho.SelectedItem.Text & Chr(39)
OleDbConnection1.Open()
Dim cmd As New OleDb.OleDbCommand()
cmd.Connection = OleDbConnection1
cmd.CommandText = myQuery
Dim datareader As OleDb.OleDbDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
dgF002.DataSource = datareader
dgF002.DataBind()
Case 1
'another SQL statement w/ a WHERE clause
Case 2
'another SQL statement w/ a WHERE clause
Case 3
'another SQL statement w/ a WHERE clause
End Select
End Sub
-
Dec 12th, 2002, 02:11 PM
#2
Wouldnt it be assumable that the where clause is looking for a value that doesnt exist in the db?
-
Dec 12th, 2002, 02:17 PM
#3
Thread Starter
Member
Cander -
Yeah, it's possible. But is my syntax with the "Chr(39)" 's correct as far as you can see?
-
Dec 12th, 2002, 05:49 PM
#4
if you want a quotation mark (") thats Char(34) :-D
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
-
Dec 13th, 2002, 08:02 AM
#5
Chr(39) is the single quote (').
You only need this if the MUFLID is of type text. If MUFLID is numeric, you should omit the chr(39)
BTW, you could have just typed the quotes.
"SELECT * FROM [tbl * F002 > 4 J] WHERE MUFLID = '" & ddlWho.SelectedItem.Text & "'"
Also make sure ddlWho.SelectedItem.Text doesn't contain single quotes!, if it does, you need to replace every single quote with two single quotes.
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
|