im going to try to explain this the best i can
the programs here are setup using adodb.connection and adodb.recordset
they run threw an odbc connecter that is on each machine in the company (i dont know, i didn't do it).

here is what i do with the adors

module moddata

private adoconnect as new adodb.connection
public adors as new adodb.recordset

public function db_adors_connect(byval strquery as string) as boolean

try

if moddata.adoconnect.state = connectionstate.open then call moddata.db_adors_close()

moddata.adoconnect.open(dsn, user, pass)
moddata.adors.open(strquery$, adoconnect, 3)
if moddata.adors.eof = false then return true

catch ex as exception

'error handling code'

end try

end function

public sub db_adors_close()
moddata.adoconnect.close
end sub

end module

then in my regular code i do the following

if moddata.db_connect("query") = true then
whateverfield.text = moddata.adors.fields("WHATEVERCOLUMN").value
end if
call moddata.db_disconnect

I have never used the mysql.data.mysqlclient, but i am interested in trying to accomplish similiar to the same thing:

i am giving it a try as of today, but having a little confusion

imports mysql.data.mysqlclient

module moddata

dim sqlConnector as mysqlconnection

public function connect_db(byval strquery as string) as boolean

try

 if moddata.sqlconnector.state = connectionstate.open then call moddata.db_close()

 sqlconnector.connectionstring = "Server=ip; Uid=yes; Pwd=no; database=;ok;"
 sqlconnector.open()

 ' i want it to do something along the lines of if recordset.eof = false then return true here

catch ex as exception

 msgbox(ex.message)

end try
end function

public sub close_db()
 sqlconnector.close
end sub

end module

hopefully i explained this ok..

Recommended Answers

All 6 Replies

sorry, what im asking is how do i return a recordset for the mysql.data.mysqlclient similiar to the way i do with the adodb.recorset?

great - i have it working the way i like but i am still left with a question

is there a way to pull a database column by its name instead of using its index ie reader(0) pulls the first column. is there a way to load by column name?

thanks again.

Yes, is you want to sort data use next SQL statement:

SELECT collumnName FROM tableName

.. i think i understand what you are saying but im not sure..

heres an example of what i mean though

sql query:

SELECT system_user, product, customer FROM sales_detail WHERE ID = 1234

in adodb .net

me.txtassociate.text = moddata.adors.fields("System_User").value
me.txtproduct.text = moddata.adors.fields("product").value
me.txtcustomer.text = moddata.adors.fields("customer").value

the same query using the mysqlclient

me.txtassociate.text = moddata.rs(0)
me.txtproduct.text = moddata.rs(1)
me.txtcustomer.text = moddata.rs(2)

can i use the mysqlreader like the adodb
example

me.txtassociate.text = moddata.rs.fields("System_User").value

... hope that clears up what i was asking

SQL Query is valid. For ADODB I don't know because I never used it. You can use get data from MySQL with ODBC.

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.