G
Guest
Hello All!
I have a value in a textbox(txbTableIDm.Text ) that I would like to use in a
paremiter in a SP I wrote, and then have the select statement work off that
parememter, retireive a diffrent value in another(txbCredits) texbox. Heres
the code:
Public Sub GetCredit()
Dim ConCred As SqlConnection
Dim strCred As String
Dim cmdCred As SqlCommand
Dim daCred As SqlDataAdapter
ConCred = New
SqlConnection("Server=localhost;UID=xxxx;PWD=xxxxxx;database=dbSTMBL")
cmdCred = New SqlCommand("GetCredit", ConCred)
cmdCred.CommandType = CommandType.StoredProcedure
Dim prmUser_To As New SqlParameter
prmUser_To.ParameterName = "@UserID"
prmUser_To.SqlDbType = SqlDbType.VarChar
prmUser_To.Size = 50
If txbTableIDm.Text <> "" Then
prmUser_To.Value = (txbTableIDm.Text)
End If
ConCred.Open()
prmUser_To.Direction = ParameterDirection.Output
cmdCred.Parameters.Add(prmUser_To)
<ERROR>Dim reader As SqlDataReader = cmdCred.ExecuteReader
txbCredits.Text = Convert.ToString(prmUser_To)
ConCred.Close()
End Sub
Just in case, here is the SP it's calling
CREATE PROCEDURE dbo.GetCredit @UserID varchar(50), @Return_Credit
Nvarchar(50) OUT
AS
SELECT @Return_Credit = Credits FROM Bankroll WHERE UserID= @UserID
return (@Return_Credit)
GO
Any thoughts?
TIA!!
Rudy
I have a value in a textbox(txbTableIDm.Text ) that I would like to use in a
paremiter in a SP I wrote, and then have the select statement work off that
parememter, retireive a diffrent value in another(txbCredits) texbox. Heres
the code:
Public Sub GetCredit()
Dim ConCred As SqlConnection
Dim strCred As String
Dim cmdCred As SqlCommand
Dim daCred As SqlDataAdapter
ConCred = New
SqlConnection("Server=localhost;UID=xxxx;PWD=xxxxxx;database=dbSTMBL")
cmdCred = New SqlCommand("GetCredit", ConCred)
cmdCred.CommandType = CommandType.StoredProcedure
Dim prmUser_To As New SqlParameter
prmUser_To.ParameterName = "@UserID"
prmUser_To.SqlDbType = SqlDbType.VarChar
prmUser_To.Size = 50
If txbTableIDm.Text <> "" Then
prmUser_To.Value = (txbTableIDm.Text)
End If
ConCred.Open()
prmUser_To.Direction = ParameterDirection.Output
cmdCred.Parameters.Add(prmUser_To)
<ERROR>Dim reader As SqlDataReader = cmdCred.ExecuteReader
txbCredits.Text = Convert.ToString(prmUser_To)
ConCred.Close()
End Sub
Just in case, here is the SP it's calling
CREATE PROCEDURE dbo.GetCredit @UserID varchar(50), @Return_Credit
Nvarchar(50) OUT
AS
SELECT @Return_Credit = Credits FROM Bankroll WHERE UserID= @UserID
return (@Return_Credit)
GO
Any thoughts?
TIA!!
Rudy