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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.