Reputation: 29
In my asp.net, VB code behind web with access database. i am using this code to bind data.
Dim comd As New OleDbCommand("SELECT ID1 FROM [Tak1] Where Section_='" + sectxt.Text + "' and status_='Open' and ID1<>""", con1)
Dim daa As New OleDbDataAdapter(cmd)
Dim dss As New DataSet()
daa.Fill(dss)
DropDownList3.Items.Clear()
DropDownList3.DataSource = dss
DropDownList3.DataTextField = "ID1"
DropDownList3.DataBind()
DropDownList3.Items.Insert(0, New ListItem("Please Select", "NA"))
Database is having some rows blank in ID1 field. data gets bind but there is blank space as there are some rows with blank ID1 as shown below
Upvotes: 0
Views: 56
Reputation: 319
Did you mean to write:
Dim comd As New OleDbCommand("SELECT ID1 FROM [Tak1] Where Section_='" + sectxt.Text + "' and status_='Open' and ID1<>""""", con1)
or, alternatively (and preferably),
Dim comd As New OleDbCommand("SELECT ID1 FROM [Tak1] Where Section_='" + sectxt.Text + "' and status_='Open' and ID1<>''", con1)
(You may have forgotten to add all the quotes you wanted, since ""
is an escape for "
)
For a similar question see here
Upvotes: 1