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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need some serious help

Status
Not open for further replies.
May 10, 2002
77
US
I just cannot get this to run. Senario: I have two drop down boxes. One is going to fill a value in the sql code for choosing the correct record, the second is what to change a value to.

strUpdate = "Update table Set OldStatus=@oldID Where ssn=@stuSSN and newstatus=@newID"
cmdUpdate = New SqlCommand( strUpdate, dbConn)
cmdUpdate.Parameters.Add( "@stuSSN", txtstuSSN.Text )
cmdUpdate.Parameters.Add( "@oldID", txtoldID.SelectedItem.Value )
cmdUpdate.Parameters.Add( "@newID", txtnewID.SelectedItem.Value )

Here is what my dropdown looks like:

<asp:DropDownList ID="txtoldID" Runat="Server">
<asp:ListItem Text="R" Value="R" />
<asp:ListItem Text="S" Value="S" />
</asp:DropDownList>

This one little tidbit is holding up from making the site live. So frustrating. When I run the page and enter the ssn and choose from the two dropdowns and click submit, it just reloads the same page and changes nothing. I get no error message or anything.
 
Have you put a break point in to make sure the above is actually executing?

Rhys
"There are some oddities in the perspective with which we see the world. The fact that we live at the bottom of a deep gravity well, on the surface of a gas-covered planet going around a nuclear fireball 90 million miles away and think this to be normal is obviously some indication of how skewed our perspective tends to be"
DOUGLAS AD
 
No. I have a book that I am trying to learn this from to build a asp.net site for coporate. So pretty much trying to learn on my own and never heard of a break point until now. I found a reference to it. I'll try that out now. Thanks! Be back shortly.
 
Have you called cmdUpdate.ExecuteNonQuery?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Yes. It is included in the code just before I close the db connection.
 
And have you checked that all of your parameters have the correct values?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Are you referring to creating watches? When I did this, the debugger just hung. So I was wondering if the code I used to add the parameters to the cmdupdate command were listed correctly?
 
Are you referring to creating watches?
No, I mean make sure that the values that you are using for the parameters actually exist and are correct.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Oh yes, sorry. Everything is declared and the values are set from within the form.
 
Can you post both the Page Load code and the sub that does the update?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 


<script runat="server">

Sub Page_Load

If Not IsPostBack Then

ViewState( "CurrentPage" ) = 1

End If





End Sub

' Hides panels

Sub Button_Click( s As Object, e As EventArgs )

DIM pnlPanel As Panel

DIM strPanelName AS String

Dim cmdUpdate As SqlCommand

Dim strUpdate As String

Dim c2000Conn As SqlConnection = New SqlConnection("Server=***;UID=***;PWD=***;Database=C2000")

c2000Conn.Open()





pnlForm1.Visible = False

pnlForm2.Visible = True





strUpdate = "Update FaFAFSA06 Set CPSStatus=@oldID Where ssn=@stuSSN and cpsstatus=@newID"

cmdUpdate = New SqlCommand( strUpdate, c2000Conn )

cmdUpdate.Parameters.Add( "@stuSSN", txtstuSSN.Text )

cmdUpdate.Parameters.Add( "@oldID", txtoldID.SelectedItem.Value )

cmdUpdate.Parameters.Add( "@newID", txtnewID.SelectedItem.Value )





cmdUpdate.ExecuteNonQuery()

c2000Conn.Close()



End Sub

</script>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top