Try cmdStr = "SELECT [idt],[col1] FROM [test];" Using conn As New SqlConnection(connStr) Using cmd As New SqlCommand(cmdStr, conn) conn.Open() cmd.ExecuteNonQuery() Using da As New SqlDataAdapter(cmd) da.Fill(ds) DropDownList1.DataSource = ds.Tables(0) DropDownList1.DataTextField = "idt" DropDownList1.DataValueField = "col1" DropDownList1.DataBind() End Using cmd.Dispose() conn.Close() conn.Dispose() End Using End Using Catch ex As Exception TextBox1.Text = ex.Message End Try
Try cmdStr = "SELECT [datetime],[col1],[col2],[col3] FROM [test] WHERE [idt]=@idt;" Using conn As New SqlConnection(connStr) Using cmd As New SqlCommand(cmdStr, conn) conn.Open() cmd.Parameters.AddWithValue("@idt", DropDownList1.DataTextField) cmd.ExecuteNonQuery() ...
cmd.Parameters.AddWithValue("@idt", DropDownList1.DataValueField)
cmd.Parameters.AddWithValue("@idt", DropDownList1.SelectedItem.Text)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)