I have a field where the user inputs a certain number. Then the user will click the button below the field to take the inputted number as a parameter and execute a stored procedure that uses the parameter as an input value. I already have the stored procedure working fine through SQL Server. I just don't know how to take this inputted value and use it as a stored procedure and execute the stored procedure. I'm not going to return any recordset. I just want to execute the procedure and perhaps say "complete" when it's executed. Below is what I have so far but I think it is far from correct for some reason. txtTranNo is the field where the user inputs the number. I know you can use this method if you know what the input param already is by replacing txtTranNo with the param but I'm not sure how to incorporate the value that the user inputs. Any suggestions/tutorials/code samples? Thanks for your time and help!! It's greatly appreciated.
VB.NET:
[size=2][/size][size=2][color=#0000ff]Protected[/color][/size][size=2] [/size][size=2][color=#0000ff]Sub[/color][/size][size=2] ResetPO_Click([/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] sender [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.Object, [/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] e [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.EventArgs)[/size][size=2][color=#0000ff]Handles[/color][/size][size=2] ResetPO.Click
[/size][size=2][color=#0000ff]Dim[/color][/size][size=2] sConnStr [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]String[/color][/size][size=2] = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Password=xxxxx;Initial Catalog=AFD;Data Source=LONGS;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=QUZ0970;Use Encryption for Data=False;Tag with column collation when possible=False"
[/size][size=2][color=#008000]
[/color][/size][size=2][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] cn [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]New[/color][/size][size=2] SqlConnection(sConnStr)
[/size][size=2][color=#0000ff]Dim[/color][/size][size=2] cmd [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]New[/color][/size][size=2] SqlCommand("sFRT_FreightResetPO", cn)
cmd.CommandType = Data.CommandType.StoredProcedure
cmd.Parameters.Add([/size][size=2][color=#0000ff]New[/color][/size][size=2] SqlParameter("@TranNo", Data.SqlDbType.VarChar, 30))
cmd.Parameters("@TranNo").Value = [/size][size=2][color=#0000ff]Me[/color][/size][size=2].txtTranNo
cn.Open()
cmd.ExecuteNonQuery()
cn.Close()
[/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]Sub
[/color][/size]