Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help using 2 stored procedures on the page behind

Status
Not open for further replies.

JJ297

Programmer
Jun 27, 2007
30
0
0
US
Can someone tell me why I am getting:

Procedure or function AddRequestorInfo has too many arguments specified.

Here's my code. I'm trying to use two stored procedures. Do I have it set up properly?

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim question As String = Txtquestion.Text

Dim conn As New Data.SqlClient.SqlConnection("Data Source=seb2a54;Initial Catalog=EDCSFAQS;Persist Security Info=True;User ID=EDCSFAQUser;Password=fax") 'this is the conn from frontpage


'add string
Dim cmd As New Data.SqlClient.SqlCommand
With cmd
.Connection = conn 'the connection
.CommandType = Data.CommandType.StoredProcedure
.CommandText "AddQuestion"
.Parameters.AddWithValue("@topicid", CInt(DropDownList1.SelectedItem.Value))
.Parameters.AddWithValue("@quesdate", QuesDate.Text)
.Parameters.AddWithValue("@questions", Txtquestion.Text)



End With

'Dim cmd As New Data.SqlClient.SqlCommand
With cmd
'.Connection = conn
.CommandType = Data.CommandType.StoredProcedure
.CommandText = "AddRequestorInfo"
.Parameters.AddWithValue("@FName", FName.Text)
.Parameters.AddWithValue("@LName", LName.Text)
.Parameters.AddWithValue("@EmailAdd", EmailAdd.Text)


End With

'Try
conn.Open()
cmd.ExecuteNonQuery() 'executes the sql that I assign. don't need anything back from db

'Catch ex As Data.SqlClient.SqlException
'Throw New ApplicationException("An error occurred while trying to insert the record")
'Finally
conn.Close()
'End Try

End Sub
 
I believe that you are overwriting the first SP with the second. Either execute the first one then clean up the command object and use it again, or create two. You're adding 6 parameters.

J
 
something more like this

Code:
   'add string
        Dim cmd As New Data.SqlClient.SqlCommand
        With cmd
            .Connection = conn 'the connection
            .CommandType = Data.CommandType.StoredProcedure
            .CommandText  "AddQuestion"
            .Parameters.AddWithValue("@topicid", CInt(DropDownList1.SelectedItem.Value))
            .Parameters.AddWithValue("@quesdate", QuesDate.Text)
            .Parameters.AddWithValue("@questions", Txtquestion.Text)



        End With

  conn.Open()
        cmd.ExecuteNonQuery() 'executes the sql that I assign. don't need anything back from db

        cmd = New Data.SqlClient.SqlCommand
        With cmd
            '.Connection = conn
            .CommandType = Data.CommandType.StoredProcedure
            .CommandText = "AddRequestorInfo"
            .Parameters.AddWithValue("@FName", FName.Text)
            .Parameters.AddWithValue("@LName", LName.Text)
            .Parameters.AddWithValue("@EmailAdd", EmailAdd.Text)


        End With

'Try
        conn.Open()
        cmd.ExecuteNonQuery() 'executes the sql that I assign. don't need anything back from db

Christiaan Baes
Belgium

"My old site" - Me
 
Thanks to you both for having patience with me. You fixed my problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top