Is this a LOGICAL ERROR or what?

pasensyoso_manigbas

Well-known member
Joined
May 19, 2006
Messages
64
Programming Experience
Beginner
dim _open as New OpenFile
Dim op As New OleDbCommand("Select * from LocationHolder", connection)
Dim r As OleDbDataReader
r = op.ExecuteReader

While r.Read

_open.cbolocation.Items.Add(r(0)) --> it will not read this part
_open.cbolocation.Items.Add(r(
"tool")) --> it will not read this part, it skips..

End While

is there something wrong.. with this or this is just a logical error or something... it confuses my state of mind..
 
Try something like this...

Public Sub OpenSQLCommand(ByVal inSQL As String)
'this sub routine executes SELECT queries
ConnectSQL()
Dim sqlCOM As New SqlCommand
sqlCOM =
New SqlCommand(inSQL, sqlCON)
sqlDR = sqlCOM.ExecuteReader(CommandBehavior.CloseConnection)
End Sub

Public Function ColumnSQL(ByVal inTable As String, ByVal inColumn As String, ByVal inWhereClause As String) As String
'this function is used to retrieve a specific value from the db
SQL = "SELECT " & inColumn _
& " FROM " & inTable _
& " WHERE " & inWhereClause
OpenSQLCommand(SQL)
While sqlDR.Read()
ColumnSQL = sqlDR(inColumn)
'do your thing here, additems to combobox
End While
sqlDR.Close()
End Function
 
Also

Please tell me what you are trying to load into the combobox. One or two different values per database row?

For one value, you only need to put in the name of the column you are trying to retrieve and the r.while will move through the records sequentially...

Please enlighten me further with very detailed details
 
will actually that code is now working properly.. i dunno why when i first invoke it.. it doesn't return anything..

now i also got another thing similar to that of the first.. it still can't read the values and releases only blank... this is in the listview now..
when i add something like..

lv.Subitems.add(_open.cbolocation.Text) --> this releases null, but cbolocation has value.

I guess theres something wrong with VB
 
This code is invoke when i click my contextmenu in the form Supplies.

dim _open as New OpenFile

dim lv as New ListViewItem

lv.Text=value1
lv.Subitems.Add(_open.cbolocation.Text) --> this wont read the value
lv.Subitems.Add(_open.cboTools.Text) --> this wont read the value
lvi.Items.Add(lv)
 
Back
Top