Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Delphi SQL Parameter Problems


  • Please log in to reply

#1
Jack Wetson

Jack Wetson

    Member

  • Member
  • PipPip
  • 10 posts
here is the code from the button click which is causing problems, if anyone wants full code just shout :) im getting an index 0 error if anyone can help that would be great

procedure TMain.Button_LvlUpClick(Sender: TObject);
var

 Calc1 :Integer;
 Calc2 :Integer;

begin
FirstRun := False;
Calc1 := 0;
Calc2 := 0;
OrderID:= SelectedID;
EUorUS:= Grid.Fields[1].AsString;
ServerName := Grid.Fields[2].AsString;
CharName:= Grid.Fields[3].AsString;
CharClass:= Grid.Fields[4].AsString;
StartLevel:= IntToStr(Grid.Fields[5].AsInteger);
EndLevel :=  IntToStr(Grid.Fields[6].AsInteger);
CurrentLevel := (Grid.Fields[7].AsInteger);
Progress:= IntToStr(Grid.Fields[8].AsInteger);
Handler:= Grid.Fields[9].AsString;


CurrentLevel:= CurrentLevel + 1;

Calc1:= StrToInt(EndLevel) - StrToInt(StartLevel);
Calc2:= (StrToInt(Progress) - (Calc1) - 1)*-1;
Progress:= IntToStr(Calc2);


ADOQuery1.Close;

ADOQuery1.Parameters.Clear;
ADOQuery1.Parameters[0].Value := Progress;
ADOQuery1.Parameters[1].Value := CurrentLevel;
ADOQuery1.Parameters[2].Value := OrderID;
ADOQuery1.SQL[0] := 'INSERT INTO Orders (Progress, CurrentLevel) VALUES(:Progress, :CurrentLevel)  WHERE OrderID = :OrderID';
ADOQuery1.ExecSQL;

ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('SELECT Orders.OrderID, Orders.[EU/US], Orders.ServerName, Orders.CharName, Orders.CharClass, Orders.StartLevel, Orders.EndLevel, Orders.CurrentLevel, Orders.Progress, Orders.Handler FROM Orders WHERE Orders.OrderID = :OrderID');
ADOQuery1.Open;

end;

  • 0

Advertisements


#2
Jack Wetson

Jack Wetson

    Member

  • Topic Starter
  • Member
  • PipPip
  • 10 posts
BUMP? ANYONE?
  • 0

#3
Ax238

Ax238

    Tech Staff

  • Technician
  • 1,323 posts
Hello Jack,

Could you tell us the exact error message you are receiving?
Also, do you know which statement is causing the error?

You can insert statements similar to the following to determine where it's coming from, if you don't have a debugger:
ShowMessage('Test 1');

Regards,

Ax

Edit: On closer inspection, it looks like you haven't set the OrderID parameter for the SELECT query. Try adding the following line of code:
ADOQuery1.Parameters[0].Value := OrderID;

  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP