I have used the SQLDesktop.cs library (with the permission of Erel) to create a desktop library to access databases via Odbc connection.
The objects, methods and properties are almost identical, except:
BeginTransaction
AddParameter
It requires Microsoft.Data.Odbc.dll that can be downloaded from here.
I would like to write a help file, but nobody would understand it due to my horrible english. Any volunteer?
v0.5 Added two methods:
FieldNames - Return a string array filled with the name of the colums.
FieldType(int) - Return a string with the type of the field
Here is a sample:
You can find various connections strings here.
The objects, methods and properties are almost identical, except:
BeginTransaction
AddParameter
It requires Microsoft.Data.Odbc.dll that can be downloaded from here.
I would like to write a help file, but nobody would understand it due to my horrible english. Any volunteer?
v0.5 Added two methods:
FieldNames - Return a string array filled with the name of the colums.
FieldType(int) - Return a string with the type of the field
Here is a sample:
B4X:
con.New1
con.Open("DSN=Sales;")
[COLOR="seagreen"]'con.Open("Driver={Microsoft Access Driver (*.mdb)};Dbq=c:\pacientes.mdb;" )
'This would be for an ODBC DSN-Less connection[/COLOR]
cmd.New1("",con.Value)
reader.New1
con.BeginTransaction(cmd.Value)
[COLOR="seagreen"]'Must specify the Command object used[/COLOR]
cmd.AddParameter("id1",cmd.typeDouble )
[COLOR="seagreen"] 'Must specify the paramater data type[/COLOR]
cmd.SetParameter("id1","9500")
cmd.AddParameter("id2",cmd.typeDouble )
[COLOR="seagreen"]'Must specify the paramater data type[/COLOR]
cmd.SetParameter("id2","9520")
cmd.CommandText="SELECT * FROM final WHERE id> ? AND id< ?"
[COLOR="SeaGreen"] 'Parameter's names don't work in ODBC with CommandText,
'so you have to write question marks that will be replaced in the order that you added the parameters.[/COLOR]
reader.Value=cmd.ExecuteReader
Do While reader.ReadNextRow
Msgbox(reader.GetValue(1))
Loop
reader.Close
con.EndTransaction
You can find various connections strings here.
Attachments
Last edited: