Dear Colleague:

How can I use "begin transaction", "commit transaction", "rollback transaction" and the like in the visual basic 6. Is it possible to populate a combobox in VB form with the data that is retrieved from SQL server database table? How the code looks like?



Recommended Answers

All 3 Replies

The workspace object has the begin/commit/rollback trans options (For Jet). If u r using SQL server, it will depend on how u r connecting to the database (ODBC, ADO, etc).

To populate a combo box from a recordset from SQL server db, simply use

Do until rs.eof
  combo1.additem rs("FieldName")

Dear colleague,

Thanks for the help, I have used it. I use ADO. But what is a workspace? is that an object that helps to make the software works in the netwrok. Pleae give me some ideas about. An one more question. is it possible to populate the combobox with a query result? How?



Workspace is an object in DAO Object Library. I have used to for accessing Access Databases using Jet. The syntax is something like

Dim ws as workspace
set ws = dbengine.workspaces(0)
Dim db as database
set db = ws.opendatabase(...)


For query results to combo box, the code in my last post would work fine. If u r using ADO,

Dim rs as ADODB.Recordset
Dim objCmd as ADODB.Command

< Code to specify Query to execute >
set rs = objCmd.Execute()

And now u can use
do until rs.eof
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.