needhelpso
Programmer
I have a dropdownbox that I select a number. I assign the value of the box to x. I then want to use x in an sql statement.
Here is the code for the button:
Sub Button1_Click(sender As Object, e As EventArgs)
Dim ds As DataSet =new DataSet()
dim x as string
x=dropdownlist1.selecteditem.value
mylabel.text=x
Dim MyCommand2 as new OleDbDataAdapter("select * from timesheet where PayPeriod=x", MyConn)
MyCommand2.Fill(ds, "payperiod"
Myrepeater.DataSource = ds.Tables("payperiod"
.DefaultView
databind()
End Sub
x will be equal to whatever I select in the drop down box (I verified that). However, this code works if I put in a number directly into:
Dim MyCommand2 as new OleDbDataAdapter("select * from timesheet where PayPeriod=12", MyConn)
However, if I enter x which contains the value of 12 like this:
Dim MyCommand2 as new OleDbDataAdapter("select * from timesheet where PayPeriod=x", MyConn)
It errors out even though the value is 12.
Any ideas?
Here is the code for the button:
Sub Button1_Click(sender As Object, e As EventArgs)
Dim ds As DataSet =new DataSet()
dim x as string
x=dropdownlist1.selecteditem.value
mylabel.text=x
Dim MyCommand2 as new OleDbDataAdapter("select * from timesheet where PayPeriod=x", MyConn)
MyCommand2.Fill(ds, "payperiod"
Myrepeater.DataSource = ds.Tables("payperiod"
databind()
End Sub
x will be equal to whatever I select in the drop down box (I verified that). However, this code works if I put in a number directly into:
Dim MyCommand2 as new OleDbDataAdapter("select * from timesheet where PayPeriod=12", MyConn)
However, if I enter x which contains the value of 12 like this:
Dim MyCommand2 as new OleDbDataAdapter("select * from timesheet where PayPeriod=x", MyConn)
It errors out even though the value is 12.
Any ideas?