Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
shobapond
Starting Member
2 Posts |
Posted - 2003-02-04 : 23:29:27
|
| Can i use a stored procedure twice in my codes? i'm trying to use a stored procedure to insert values but when it is goingto execute the second time it produces and error.. anybody has a solutionfor this problem? If CheckBox1.Checked = True ThenmyConnection2.Open()objCommand2.CommandText = "gb1_ans_insert"objCommand2.CommandType = CommandType.StoredProcedurecase_id.TextobjCommand2.Parameters.Add("@qu_id", SqlDbType.Int).Value = "1"objCommand2.Parameters.Add("@ans_des",SqlDbType.VarChar).Value= "Uneventful"objCommand2.Parameters.Add("@ans_id", SqlDbType.Int).Value ="1"objCommand2.Parameters.Add("@ans_response", SqlDbType.Int).Value= "1"objCommand2.ExecuteNonQuery()ElseIf CheckBox1.Checked = False ThenMessageBox.Show("not checked")End IfIf CheckBox2.Checked = True ThenobjCommand2.CommandText = "gb1_ans_insert"objCommand2.CommandType = CommandType.StoredProcedureobjCommand2.Parameters.Add("@case_id", SqlDbType.VarChar).Value= case_id.TextobjCommand2.Parameters.Add("@qu_id", SqlDbType.Int).Value = "1"objCommand2.Parameters.Add("@ans_des", SqlDbType.VarChar).Value= "HIE"objCommand2.Parameters.Add("@ans_id", SqlDbType.Int).Value ="2"objCommand2.Parameters.Add("@ans_response", SqlDbType.Int).Value= "1"objCommand2.ExecuteNonQuery()ElseIf CheckBox2.Checked = False ThenMessageBox.Show("not checked")End IfmyConnection2.Close()Thanks in advance for your help |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2003-02-04 : 23:41:25
|
| You only open the connection if CheckBox1.Checked = TrueFor the second query you will have to clear the parameters as they will still be bound to the command from the first execDo you have a transaction anywhere to make sure this doesn't half succeed?You've posted on 2 of the 4 sites I'm monitoring at the moment - see if you can get the other 2 :).==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy.Edited by - nr on 02/04/2003 23:46:27 |
 |
|
|
shobapond
Starting Member
2 Posts |
Posted - 2003-02-05 : 01:28:17
|
| Hi Thanks a lot for your help been helpful to me!!!BTW you in which 2 other forums ? ;)cheers |
 |
|
|
|
|
|