G
Guest
Hello everyone
can you please help me in finding out how i can bind a column to a
dropdownlist at run time. I'm using vb.net with sql server 2000. Its for a
web development
i tried this but it never worked
With Dropdownlist1
.DataSource = CreateDataSet(strSQL2)
.DataBind()
end with
Private Function CreateDataSet(ByVal strSQL As String, _
Optional ByVal sqlParam As SqlParameter = Nothing) As DataSet
Dim scnnNW As New SqlConnection(strConn)
' A SqlCommand object is used to execute the SQL commands.
Dim scmd As New SqlCommand(strSQL, scnnNW)
If Not IsNothing(sqlParam) Then
scmd.Parameters.Add(sqlParam)
End If
' A SqlDataAdapter uses the SqlCommand object to fill a DataSet.
Dim sda As New SqlDataAdapter(scmd)
' Create and Fill a new DataSet.
Dim ds As New DataSet
sda.Fill(ds)
Return ds
End Function
Thank you
can you please help me in finding out how i can bind a column to a
dropdownlist at run time. I'm using vb.net with sql server 2000. Its for a
web development
i tried this but it never worked
With Dropdownlist1
.DataSource = CreateDataSet(strSQL2)
.DataBind()
end with
Private Function CreateDataSet(ByVal strSQL As String, _
Optional ByVal sqlParam As SqlParameter = Nothing) As DataSet
Dim scnnNW As New SqlConnection(strConn)
' A SqlCommand object is used to execute the SQL commands.
Dim scmd As New SqlCommand(strSQL, scnnNW)
If Not IsNothing(sqlParam) Then
scmd.Parameters.Add(sqlParam)
End If
' A SqlDataAdapter uses the SqlCommand object to fill a DataSet.
Dim sda As New SqlDataAdapter(scmd)
' Create and Fill a new DataSet.
Dim ds As New DataSet
sda.Fill(ds)
Return ds
End Function
Thank you