0

Hi
I worte this code can any body tell me why its not working
Error can be seen in the attached file whis….
Value cannot be null.
Parameter name : data source


Private Sub btnTotal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTotal.Click
Dim ConnectionString As String = "Integrated Security=SSPI; Persist Security Info=False; Initial Catalog=NewBase; Data Source=CP"
Dim conn As New SqlConnection(ConnectionString)
Dim cmdstr As String = "select SUM(itprice)as total from trick where itname='" & txtSearch.Text & "'"
Dim DataAdapter As New SqlDataAdapter(cmdstr, conn)
DataAdapter.Fill(ds)
conn.Close()
Try
txtTotal.DataBindings.Add("Text", ds.Tables("trick"), "total")
Catch ex As Exception
MsgBox(ex.Message)
End Try

End Sub

Attachments
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by maczoon
0

Try This

Private Sub btnTotal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTotal.Click
Dim ConnectionString As String = "Integrated Security=SSPI; Persist Security Info=False; Initial Catalog=NewBase; Data Source=CP"
Dim conn As New SqlConnection(ConnectionString)
Dim cmdstr As String = "select SUM(itprice)as total from trick where itname='" & txtSearch.Text & "'"
Dim DataAdapter As New SqlDataAdapter(cmdstr, conn)
DataAdapter.Fill(ds)
conn.Close()
Try
txtTotal.DataBindings.Add("Text", DataAdapter .Tables("trick"), "total")
Catch ex As Exception
MsgBox(ex.Message)
End Try

End Sub

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.