need help,,asp.net and sql update problem
hiiii..i am using asp.net 2005 in VB language and sqlserver 2005..in my form i am using 2 dropdownlist boxes..if i select a name in the dropdown list box1 then the corresponding last name is selected in the dropdwon listbox2...till now everything is working fine,,,now if i want to change the lastname(tht means select different surname for tht name)and press update button it doesnot get updated....,,,,how do i achieve ths,,,
in short i want to update dropdown list box 2 with the new selected item for the corresponding name in dropdown listbox1..
pls help,,,reply asap,,
thnks in advance
johnny.g
Junior Poster in Training
91 posts since Feb 2008
Reputation Points: 10
Solved Threads: 3
guys i m waiting for ur reply,,,,,,pls help asap
johnny.g
Junior Poster in Training
91 posts since Feb 2008
Reputation Points: 10
Solved Threads: 3
do i need to paste my whole code
johnny.g
Junior Poster in Training
91 posts since Feb 2008
Reputation Points: 10
Solved Threads: 3
code on submit button>>>>
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
If (DropDownList1.SelectedValue.Equals("Standard")) Then
st = "Menu_Standard"
Else
st = "Menu_User"
End If
Dim str10 As String
str10 = "select SUB_ID from " & st & " where ID=" & DropDownList2.SelectedValue
cmd = New SqlCommand(str10, conn)
da = cmd.ExecuteReader
Dim ramram As Integer
If da.Read = True Then
If (da.Item("SUB_ID").ToString = "") Then
ramram = 0
Else
ramram = da.Item("SUB_ID").ToString
End If
End If
da.Close()
Dim myName As String = ""
If ramram = 0 Then
myName = ""
str10 = ""
Else
str10 = "select MENU_NAME from " & st & " where ID=" & ramram
cmd = New SqlCommand(str10, conn)
da = cmd.ExecuteReader
If da.Read = True Then
myName = da.Item("MENU_NAME").ToString
End If
da.Close()
End If
str10 = "update " & st & " set"
If TextBox4.Text = "" Then
Else
str10 = str10 & " MENU_NAME='" & TextBox4.Text & "',"
End If
If CheckBox1.Checked Then
str10 = str10 & " NODE='True',"
Else
str10 = str10 & " NODE='False', LINK='" & TextBox2.Text & "', QUERY='" & TextBox3.Text & "',"
End If
If TextBox1.Text = "" Then
str10 = str10 & " DESCRIPTION=''"
Else
str10 = str10 & " DESCRIPTION='" & TextBox1.Text & "'"
End If
If myName = DropDownList3.SelectedItem.Text Then
str10 = str10 & ", SUB_ID=" & DropDownList3.SelectedValue
MsgBox(str10)
End If
str10 = str10 & " where MENU_NAME='" & DropDownList2.SelectedItem.Text & "'"
MsgBox(str10)
cmd = New SqlCommand(str10, conn)
Try
da = cmd.ExecuteReader
Catch ex As Exception
MsgBox(ex.Message)
End Try
da.Close()
conn.Close()
do i need to paste my whole code
hi bala here is ma code
johnny.g
Junior Poster in Training
91 posts since Feb 2008
Reputation Points: 10
Solved Threads: 3
Just curious..
Why are you calling an ExecuteReader with an update query?
Shouldn't you be using an ExecuteNonQuery instead?
dude it doesnt take da withexecute non reader
ne idea how to do it
johnny.g
Junior Poster in Training
91 posts since Feb 2008
Reputation Points: 10
Solved Threads: 3
fine,,let me clear maslf 1ce again....in detail
i have 3 dropdownlist in ma page,,ok,,on selecting a value frm 1st dropdownlist,,dropdownlist 2 gets updated with its corresponding value,,,now if i select a value from dropdownlist2 the corresponding value gets selected in dropdownlist3.....till now all is working fine...now,,if i select a different value in dropdownlist3 and press the update button,i m not able to get the new value(i.e the new selected value)..hope u got ma problem
johnny.g
Junior Poster in Training
91 posts since Feb 2008
Reputation Points: 10
Solved Threads: 3
Yes ..I got it that far..
So is it giving you any error while updating?
If yes, can you post that as well.
If no, well we 'll think of that part later.
no bala,,it is not giving any kind of error,,,i am not able to get the new value of dropdownlist3,,,let me clarify 1ce again if u still didnt get it,,let me kno,,thnks in advance
johnny.g
Junior Poster in Training
91 posts since Feb 2008
Reputation Points: 10
Solved Threads: 3