select count statement using form field as parameter
Posted on 2006-05-05
I have a form that is assigned a unique number (ARN) when the form loads, I need to use this number in a select count (*) as OffenseNumber where ARN = ARN.text (on the form)
How can I make the parameters for the query be the ARN.text value? Below are some of my thoughts and attempts.
Dim conn As New System.Data.SqlClient.SqlConnection("Persist Security Info=True;Server=xxx.xxx.xxx.xxx;Database=Database Name;uid=uid;network=dbmssocn;password=password")
Dim da As New System.Data.SqlClient.SqlDataAdapter("Select * from tblOffense", conn)
Dim ds As New System.Data.DataSet
Offense_Number.Text = System.Data.SqlClient.SqlDataAdapter("Select count (*) as offensecount from tbloffense where ARN = '" & ARN.Text & "';")
Additionally, when the select count statement runs, I need to add 1 to it. So if the query return a count of (2) for ARN 7777777777, then Offense_Number.text would be 3
If this makes any sense, please help!
Please be specific with your answers, I am a self taught newbie.