VBdotnet2005
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
ASKER
"Try doing a QA check on Date1.Text: IsDate(Trim(Date1.Text))"
I tried it. Result in the same error.
I tried it. Result in the same error.
ASKER
the date is fine.
Next I'd capture the SQL statement via debug and see if it worked in the SQL Query Analyzer
ASKER
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I tried Try block and other suggestions, but got same error - Incorrect syntax near '='.
ASKER
My bad, I figured out. Thanks
Try doing a QA check on Date1.Text: IsDate(Trim(Date1.Text))