Hi All
The code below is generated by the SQL Select Genie
How would I get the value of the data into a new variables there are two columns in the Select, Database & Qno. so var->Vdatabase & Var->Vqno
The select will on ever return one row of data.
Code
Kind Regards
Andy
The code below is generated by the SQL Select Genie
How would I get the value of the data into a new variables there are two columns in the Select, Database & Qno. so var->Vdatabase & Var->Vqno
The select will on ever return one row of data.
Code
HTML Code:
'Execute a query on a SQL database 'DIM a connection variable DIM cn as SQL::Connection dim flagResult as l flagResult = cn.open("{A5API=MySQL,Server='localhost',Port='3306',UserName='root',Password='������',Database='tamissqlv5'}") if flagResult = .f. then ui_msg_box("Error","Could not connect to database. Error reported was: " + crlf() + cn.CallResult.text) end end if 'Specify if you are using Portable SQL syntax, or not cn.PortableSQLEnabled = .t. 'Dim a SQL arguments object, create arguments and set their values DIM args as sql::arguments if a5_eval_valid_expression("=Var->vDatabase",local_variables()) then args.add("Vtable",convert_type(a5_eval_expression("=Var->vDatabase",local_variables()),"C")) end If if a5_eval_valid_expression("=Var->vQ_Goto",local_variables()) then args.add("Vnumber",convert_type(a5_eval_expression("=Var->vQ_Goto",local_variables()),"C")) end If 'Define the ResultSet object dim rs as sql::resultset 'Define a DataSource object delete ds dim ds as p ds.connectionstring = "{A5API=MySQL,Server='localhost',Port='3306',UserName='root',Password='������',Database='tamissqlv5'}" ds.SQLSelectstatement = <<%sql% SELECT DATABASE, QNO FROM questions WHERE ((DATABASE = :Vtable) AND (QNO = :Vnumber)) %sql% ds.type = "ad hoc" ds.sqltype = "Portable" ds.arguments = <<%txt% <Arguments<[1]<variablename="Vtable"> <prompt="Vtable"> <type="Character"> <style="TextBox"> <default_value="=Vdatabase"> <helptext=""> <choices=""> <maximumvalue=""> <minimumvalue=""> > <[2]<variablename="Vnumber"> <prompt="Vnumber"> <type="Character"> <style="TextBox"> <default_value="=VQ_goto"> <helptext=""> <choices=""> <maximumvalue=""> <minimumvalue=""> > > <DialogTitle="Specify Argument Values"> <OKButtonLabel="&OK"> <CancelButtonLabel="&Cancel"> %txt% delete resP dim resP as p hourglass_cursor(.t.) 'specify that when the ResultSet is created, A5 should not perform a second query ' to get the count of the number of records in the ResultSet dim flagGetRecordCount as l = .f. 'Call a high level function that creates a ResultSet from a DataSource defintion. 'This function will automatically prompt for missing argument values if necessary. resP = a5_SQL_RS_From_DataSourceDef(flagGetRecordCount,cn,ds,rs,args) if resP.Error = .t. then ui_msg_box("Error",resp.errorText) cn.close() end end if 'The sql_resultset_preview() function opens a window showing a table with the results 'of your query. Show a maximum of 1,000 rows of data 'Note that the connection object is passed into the sql_resultset_preview() function so that the 'function can immediately release the resultset, thereby releasing any locks on the database that some databases might 'have applied. sql_resultset_preview(rs,1000,"Preview Query Results",cn) 'Now, close the connection cn.close()
Andy
Comment