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

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.