K Kiran Raotole Active Member Licensed User Aug 9, 2018 #1 i make function to get value of any field :: Code: Copy Sub function(sqlite As SQL,book As String,accode As String,return_field) As String Return sqlite.ExecQuerySingleResult2("select '" & return_field & "' from GL where FBOOK = ? and FACCODE = ?", _ Array As String(book,accode)) End Sub this command return field name I want field value
i make function to get value of any field :: Code: Copy Sub function(sqlite As SQL,book As String,accode As String,return_field) As String Return sqlite.ExecQuerySingleResult2("select '" & return_field & "' from GL where FBOOK = ? and FACCODE = ?", _ Array As String(book,accode)) End Sub this command return field name I want field value
Erel B4X founder Staff member Licensed User Longtime User Aug 9, 2018 #2 It will return the value. Upvote 0
M Mahares Expert Licensed User Longtime User Aug 9, 2018 #3 Kiran Raotole said: this command return field name I want field value Click to expand... You need to get rid of the single quotes in return_field in the statement. See correct code below: Code: Copy Sub function(sqlite As SQL,book As String,accode As String,return_field) As String Return sqlite.ExecQuerySingleResult2("select " & return_field & " from GL where FBOOK = ? and FACCODE = ?", _ Array As String(book,accode)) End Sub Upvote 0
Kiran Raotole said: this command return field name I want field value Click to expand... You need to get rid of the single quotes in return_field in the statement. See correct code below: Code: Copy Sub function(sqlite As SQL,book As String,accode As String,return_field) As String Return sqlite.ExecQuerySingleResult2("select " & return_field & " from GL where FBOOK = ? and FACCODE = ?", _ Array As String(book,accode)) End Sub
K Kiran Raotole Active Member Licensed User Aug 10, 2018 #4 Mahares said: You need to get rid of the single quotes in return_field in the statement. See correct code below: Code: Copy Sub function(sqlite As SQL,book As String,accode As String,return_field) As String Return sqlite.ExecQuerySingleResult2("select " & return_field & " from GL where FBOOK = ? and FACCODE = ?", _ Array As String(book,accode)) End Sub Click to expand... thanks it works. Upvote 0
Mahares said: You need to get rid of the single quotes in return_field in the statement. See correct code below: Code: Copy Sub function(sqlite As SQL,book As String,accode As String,return_field) As String Return sqlite.ExecQuerySingleResult2("select " & return_field & " from GL where FBOOK = ? and FACCODE = ?", _ Array As String(book,accode)) End Sub Click to expand... thanks it works.
R RichardN Well-Known Member Licensed User Longtime User Aug 10, 2018 #5 In the interests of keeping code as readable as possible I always name my own variables and sqlite fields with descriptive mixed-case names and construct SQL Queries using capitals for Sqlite reserved words. It is only a small detail but when queries (or their concantation) become complicated it makes it far easier to read. Like this: Code: Copy Return Sqlite.ExecQuerySingleResult2("SELECT " & ReturnField & " FROM Gl WHERE Fbook = ? AND FacCode = ?", Array As String(Book,AcCode)) For what it's worth....... Upvote 0
In the interests of keeping code as readable as possible I always name my own variables and sqlite fields with descriptive mixed-case names and construct SQL Queries using capitals for Sqlite reserved words. It is only a small detail but when queries (or their concantation) become complicated it makes it far easier to read. Like this: Code: Copy Return Sqlite.ExecQuerySingleResult2("SELECT " & ReturnField & " FROM Gl WHERE Fbook = ? AND FacCode = ?", Array As String(Book,AcCode)) For what it's worth.......
Diceman Active Member Licensed User Aug 11, 2018 #6 Kiran Raotole said: i make function to get value of any field :: Code: Copy Sub function(sqlite As SQL,book As String,accode As String,return_field) As String Return sqlite.ExecQuerySingleResult2("select '" & return_field & "' from GL where FBOOK = ? and FACCODE = ?", _ Array As String(book,accode)) End Sub this command return field name I want field value Click to expand... Aren't you missing "as string" in the argument list for "return_field"? Sub function(sqlite As SQL,book As String,accode As String,return_field as String) As String I assume the value you are returning is a simple value like a string or numeric? And not a bitmap? Upvote 0
Kiran Raotole said: i make function to get value of any field :: Code: Copy Sub function(sqlite As SQL,book As String,accode As String,return_field) As String Return sqlite.ExecQuerySingleResult2("select '" & return_field & "' from GL where FBOOK = ? and FACCODE = ?", _ Array As String(book,accode)) End Sub this command return field name I want field value Click to expand... Aren't you missing "as string" in the argument list for "return_field"? Sub function(sqlite As SQL,book As String,accode As String,return_field as String) As String I assume the value you are returning is a simple value like a string or numeric? And not a bitmap?
M Mahares Expert Licensed User Longtime User Aug 11, 2018 #7 Diceman said: Aren't you missing "as string" in the argument list for "return_field"? Click to expand... It defaults to String if declaration is missing (warning #5), but it will work. It is the column name, so most likely a string. Upvote 0
Diceman said: Aren't you missing "as string" in the argument list for "return_field"? Click to expand... It defaults to String if declaration is missing (warning #5), but it will work. It is the column name, so most likely a string.