Results 1 to 5 of 5

Thread: WHERE (not Santa) clause question..

  1. #1

    Thread Starter
    Member Ooogaleee's Avatar
    Join Date
    Nov 2002
    Location
    Jacksonville, FL
    Posts
    52

    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

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Wouldnt it be assumable that the where clause is looking for a value that doesnt exist in the db?
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Member Ooogaleee's Avatar
    Join Date
    Nov 2002
    Location
    Jacksonville, FL
    Posts
    52
    Cander -

    Yeah, it's possible. But is my syntax with the "Chr(39)" 's correct as far as you can see?

  4. #4
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403
    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.

  5. #5
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    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
  •  



Click Here to Expand Forum to Full Width