Forum Discussion

raghu_kamalapur's avatar
raghu_kamalapur
Frequent Visitor
10 years ago

I need help in executing query and that should stored in recordset variable.

I am using ADO commands for executing query and I tried to execute simple query and assign recordset as avariable. while debugging I am not able to see any data.   Below is function written    ...
  • Ryan_Moran's avatar
    10 years ago

    Try removing this line:

    aRecSet["MoveFirst"]();

     Seems like the recordset should already be at the first row.

     

    Also your command text seems to just be a table name? Are you passing the entire statement as db_table_name?

    Perhaps you mean to pull everything from the table specified like so?:

     

    aCmd["CommandText"] = "Select * from " + db_table_name; // Table name

     

    Resulting in:

    function GetRecordSet( db_table_name ) 
    {
    var projectName = "xyz";
    var aCon1, aCmd, aRecSet;
    aCon1 = ADO["CreateConnection"]();
    aCon1["ConnectionString"] = "Provider="SQLNCLI11;Server=localhost;" +"Database=" + projectName + "Data;Integrated Security=SSPI;"; 
    aCon1["Open"](); 
    aCmd = ADO["CreateCommand"](); // Creates a command and specifies its parameters
    aCmd["ActiveConnection"] = aCon1; // Connection
    aCmd["CommandType"] = adCmdTable; // Command type
    aCmd["CommandText"] = "Select * From " + db_table_name; // Table name
    aRecSet = aCmd["Execute"]();
    return aRecSet; 
    }