Sqlite Interface

drj

Member
Licensed User
Longtime User
Can you help me with equivalent calls in your system.

How do I go about convert this code. In this code I deal directly with SQLite via DLL calls.

Thanks

Public Sub ReadFunctions()


Equation = " "

Formula = " "

Answertxt = " "

Dim rowid As Integer
rowid = 1


myQuery = "select * FROM functions WHERE rowid=?"


SQLOK = Prepare2(db, myQuery, myQuery.Length, init_statement, IntPtr.Zero)


Dim errmsg As String

If (Prepare2(db, myQuery, -1, init_statement, IntPtr.Zero) <> SQLITE_OK) Then

errmsg = "Error: failed to prepare statement with message ." + GetErrmsg(db).ToString
errmsg = errmsg

Return

End If



Try


SQLOK = BindInt(init_statement, 1, rowid)

SQLOK = SqlStep(init_statement)

If SQLOK = SQLITE_ROW Then

DecimalPlaces = ColumnDouble(init_statement, 1)
xEntry = ColumnDouble(init_statement, 2)
yEntry = ColumnDouble(init_statement, 3)

xEntry = xEntry
yEntry = yEntry


SciIn = ColumnDouble(init_statement, 4)
SciOut = ColumnDouble(init_statement, 5)

Angle = ColumnDouble(init_statement, 6)
ButtonClicked = ColumnDouble(init_statement, 7)

Equation = ColumnString(init_statement, 8)
If Equation = "" Then Equation = " "
Formula = ColumnString(init_statement, 9)
If Formula = "" Then Formula = " "
Answertxt = ColumnString(init_statement, 10)
If Answertxt = "" Then Answertxt = " "



xhi = ColumnDouble(init_statement, 11)
xlo = ColumnDouble(init_statement, 12)
xincr = ColumnDouble(init_statement, 13)

rootshi = ColumnDouble(init_statement, 14)
rootslo = ColumnDouble(init_statement, 15)
rootsformula = ColumnString(init_statement, 16)
If rootsformula = "" Then rootsformula = " "
derivativex = ColumnDouble(init_statement, 17)
derivativeformula = ColumnString(init_statement, 18)
If derivativeformula = "" Then derivativeformula = " "

integralhi = ColumnDouble(init_statement, 19)
integrallo = ColumnDouble(init_statement, 20)
integralformula = ColumnString(init_statement, 21)
If integralformula = "" Then integralformula = " "
integralsteps = ColumnDouble(init_statement, 22)

End If

SQLOK = Finalize(init_statement)

SQLOK = SQLOK

Return


Catch e1 As Exception


SQLOK = SQLOK
SQLOK = SQLOK

Return

End Try







End Sub

Public Sub SaveFunctions()





Dim myQuery As String

Dim rowid As Integer

rowid = SelectedSaveCase
rowid = 1



myQuery = "UPDATE Functions SET decimals=?,x=?,y=?, sinput=?, soutput=?,radians=?,operation=?,Equation=?,Formula=?,Answer=?,xhi=?,xlo=?,xincr=?,rootshi=?,rootslo=?,rootsFormula=?,derivativex=?,derivativeFormula=?,integralhi=?,integrallo=?,integralFormula=?,integralsteps=? WHERE rowid=? "

Dim errmsg As String

If (Prepare2(db, myQuery, -1, update_statement, IntPtr.Zero) = SQLITE_OK) Then

Else

errmsg = "Error: failed to prepare statement with message '%s'." + GetErrmsg(db).ToString

Return

End If


SQLITE_TRANSIENT = New IntPtr(-1)


BindDouble(update_statement, 1, DecimalPlaces)
BindDouble(update_statement, 2, xEntry)
BindDouble(update_statement, 3, yEntry)
BindDouble(update_statement, 4, SciIn)
BindDouble(update_statement, 5, SciOut)
BindDouble(update_statement, 6, Angle)
BindDouble(update_statement, 7, ButtonClicked)
BindText(update_statement, 8, Equation, -1, SQLITE_TRANSIENT)
BindText(update_statement, 9, Formula, -1, SQLITE_TRANSIENT)
BindText(update_statement, 10, Answertxt, -1, SQLITE_TRANSIENT)
BindDouble(update_statement, 11, xhi)
BindDouble(update_statement, 12, xlo)
BindDouble(update_statement, 13, xincr)

BindDouble(update_statement, 14, rootshi)
BindDouble(update_statement, 15, rootslo)
BindText(update_statement, 16, rootsformula, -1, SQLITE_TRANSIENT)
BindDouble(update_statement, 17, derivativex)
BindText(update_statement, 18, derivativeformula, -1, SQLITE_TRANSIENT)
BindDouble(update_statement, 19, integralhi)
BindDouble(update_statement, 20, integrallo)
BindText(update_statement, 21, integralformula, -1, SQLITE_TRANSIENT)
BindDouble(update_statement, 22, integralsteps)



BindInt(update_statement, 23, rowid)


Dim success As Integer

success = SqlStep(update_statement)

Reset(update_statement)


If (success <> SQLITE_DONE) Then

success = success

Else

success = success
End If


success = Finalize(update_statement)

success = success




End Sub
 
Top