Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello,

 

I am filling a combobox from a dataset and want to add

"--select table --" as the first value of this combobox.

 

But my code is not working.

 

What am I doing wrong?

 

Thank you,

 

Burak

 

--------------

 

strsql = "select TABLE_NAME from user_tables " & _

"where TABLE_NAME <> '" + Replace(strTable, "'", "''") + "'"

da = New OleDbDataAdapter(strsql, objconnection)

da.Fill(ds, "tables")

 

Dim firstItem As New ListViewItem("-- select table -- ", 0)

lstFrgnTables.Items.Add(firstItem)

 

' fill lstFrgnTables combo box

lstFrgnTables.DataSource = ds.Tables(0)

lstFrgnTables.DisplayMember = "TABLE_NAME"

lstFrgnTables.ValueMember = "TABLE_NAME"

Posted

When I do that , it comes back with

 

"cast from datarowview to string is not valid"

 

even when i add a tostring after it, io get an error

 

' fill lstFrgnTables combo box

lstFrgnTables.DataSource = ds.Tables(0)

lstFrgnTables.DisplayMember = "TABLE_NAME"

lstFrgnTables.ValueMember = "TABLE_NAME"

 

Dim firstItem As New ListViewItem("-- select table -- ", 0)

lstFrgnTables.Items.Add(firstItem).ToString()

Posted

If your db supports UNION, you can try:

 

strsql = "SELECT '-- select table --' UNION " &

"select TABLE_NAME from user_tables " & _

"where TABLE_NAME <> '" + Replace(strTable, "'", "''") + "'"

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...