ASP Forum
VB 2005 old style
blakord | Posted 10:07am 4. February 2008 Server Time |

Hiya all, Visual Basic 2005 is so easy for put dBase values into data objects like fields and datagrids, but I can't find the way to put any value from the data base into any vars like the old VB 6 or ASP, example

' READ
Some QueryString and conditions
Open Dbase using QueryString
While NOT EOF
   x=x+1
   var(x)=dbase("some_field_name")
Wend
Close

' UPDATE
Open Dabase
Some field = var(1) where condition
Exec query
close

' DEL
Del from dBase where any field = Var(1)
Exec
Close

I'm so tired searching the method in the MSDN and web pages, I'm considering get back to VB 6, some one can hell me with the code for read the dbase and give the fields values to vars??

Thanks again
enigma | Posted 12:56am 5. February 2008 Server Time |

blakord,

I am not sure what you are trying to achieve and am wondering if just knowing the result set record count, ahead of your code's logic, would be beneficial.  If so, then something like the following may work for you:

SELECT COUNT(*) record_count
FROM <my_object_name>

... and just call it via the ADO call as you are probably doing in your code.  As far as the datagrid visual object, I am unaware of how it is programmed / referenced within VB 2005.

If you are in need of knowing how to enumerate column names by specifying a database object (e.g. table or view), just let me know and I will respond.

Cheers,
enigma
blakord | Posted 8:51am 6. February 2008 Server Time |

Thanks but my problem is not the query, is the ADO method, I just need in VB 2005 read the MS ACCESS dBase and give the values of some fields to vars

VB 2005 have an automatic dBase conection to some data objects like datagrids, but I need read from code field to field and get that values to vars, manipulate the vars values and get a new values from vars to dBase for update it, I can't find examples of this in web pages and MSDN

Thanks
blakord | Posted 7:39am 15. February 2008 Server Time |

Well just testing in VB 2005 I find how read the dBase by code only without use data objects, an example:


Option Explicit On
Imports System.Data
Imports System.Data.OleDb

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

' NOW ON LOAD FORM

'Declare variables and objects
DIM strConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\dBase.mdb;"

Dim objConnection As New OleDbConnection(strConnectionString)
Dim strSQL As String = "SELECT * FROM CONFIG"
Dim objCommand As New OleDbCommand(strSQL, objConnection)
Dim objDataAdapter As New OleDbDataAdapter(objCommand)
Dim objDataTable As New Data.DataTable("CONFIG")
Dim objDataRow As DataRow

'Open the database connection
objConnection.Open()

'Fill the DataTable object
objDataAdapter.Fill(objDataTable)

For Each objDataRow In objDataTable.Rows
    CFG_CAB_IMP_EXT = objDataRow.Item("CAB_IMP_EXT").ToString
    CFG_CAB_IMP_COM = objDataRow.Item("CAB_IMP_COM").ToString
    CFG_CAB_DIR = objDataRow.Item("CAB_DIR").ToString
Next
'Close the database connection
objConnection.Close()

'Clean up
objDataRow = Nothing
objDataTable.Dispose()
objDataTable = Nothing
objDataAdapter.Dispose()
objDataAdapter = Nothing
objCommand.Dispose()


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

Now the question is the syntax for add, update and delete

Thanks again


Reply to Post VB 2005 old style



Back to Forum Page