Forum Discussion

piasek's avatar
piasek
New Contributor
7 years ago

Return general SQL Query results

Hi, I am trying to create a few methods handling my DB connection. What I need is a simple: SELECT * FROM TABLE result. The only help I could find is some CreateADOquery method, which seems to be very awkward to use, as all the examples include addressing specific columns. And I don't want to do that.

w.SQL = "SELECT VendorName FROM Vendors WHERE State = :Param_State"
w.Open()
w.First()

while not w.EOF:
Log.Message(w.FieldByName("VendorName").AsString)

w.Next()
  

 The above example would be just right, except it requires FieldByName() method. What I am trying to get is query result as list of strings or array of strings. 
The code is being developed in Python.

2 Replies

  • you should be able to use fieldcount and field[] array

    example in delphi but you can see the point here.

    function  GetQuery(s:string):string;
    var
      i;
      q;
    begin
      q := CreateAndOpenQuery(s); // my own routine just to create and open adoquery
      result := '';
      while not q.eof do
      begin
        for i := 0 to q.fieldcount-1 do
          result := result + q.field[i].asstring+#9;
        result := result +#13;
        q.next;
      end;  
    end;
    • piasek's avatar
      piasek
      New Contributor

      Thanks, I'm going to try that and we'll see.