Link to home
Start Free TrialLog in
Avatar of VBdotnet2005
VBdotnet2005Flag for United States of America

asked on

sqladapter - fill method

I keep getting an error here - da.fill(ds, "table1")  It looks good to me.

I keep getting an error here - da.fill(ds, "table1")  It looks good to me.
 
 
 
 
 
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
 
        Dim myconstring As String = WebConfigurationManager.ConnectionStrings("myConnectionString").ToString
        Dim mycon As New SqlConnection(myconstring)
        Dim selecteddate As String = "select [datetime], accountnumber  from mytable where ([datetime] >= convert(datetime, '" & Trim(Date1.Text) & " 00:00:00', 101)) and ([datetime] <= CONVERT(DATETIME, '" & Trim(Date1.Text) & " 23:59:59' , 101 ))"
 
        Dim da As New SqlDataAdapter(selecteddate, mycon)
        Dim ds As New DataSet
 
 
        da.Fill(ds, "table1")   - ----------- Incorrect syntax near '='.
 
        Me.GridView1.DataSource = ds.Tables("table1")
        Me.GridView1.DataBind()
 
 
    End Sub

Open in new window

Avatar of rheitzman
rheitzman
Flag of United States of America image

It's likely the error is in the SQL which probably got executed at .Fill time.

Try doing a QA check on Date1.Text: IsDate(Trim(Date1.Text))
Avatar of VBdotnet2005

ASKER

"Try doing a QA check on Date1.Text: IsDate(Trim(Date1.Text))"
I tried it. Result in the same error.
the date is fine.
Next I'd capture the SQL statement via debug and see if it worked in the SQL Query Analyzer
I tried it in Sql Analyzer, it looks fine. Do you think it might be,  da.Fill(ds, "table1")  ? Could be cach?
ASKER CERTIFIED SOLUTION
Avatar of rheitzman
rheitzman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I tried Try block and other suggestions, but got same error - Incorrect syntax near '='.
My bad, I figured out. Thanks