Welcome Guest ( Log In | Join )

Discover the best free computer help!
Learn more about Geeks to Go by taking the tour. Want to ask a question, reply to a topic, or remove all advertising? It's easy, fast and free. Join today!
Spyware, virus, trojan, fake security or privacy alerts? Please start with our malware cleaning guide.
     
 
Reply to this topicStart new topic
Delphi SQL Parameter Problems
Jack Wetson
post Jul 11 2008, 06:11 AM
Post #1


New Member
*
Posts: 7
OS: Windows Vista Business SP 1



here is the code from the button click which is causing problems, if anyone wants full code just shout smile.gif im getting an index 0 error if anyone can help that would be great

CODE
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;
Go to the top of the page
 
+Quote Post
Jack Wetson
post Jul 13 2008, 10:36 AM
Post #2


New Member
*
Posts: 7
OS: Windows Vista Business SP 1



BUMP? ANYONE?
Go to the top of the page
 
+Quote Post
Ax238
post Jul 14 2008, 10:25 PM
Post #3


TA Moderator
Group Icon
Posts: 1,281
From: SET HOMEPATH
OS: Windows 95/98/2000/XP/Vista



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:
CODE
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:
CODE
ADOQuery1.Parameters[0].Value := OrderID;
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 


RSS Time is now: 9th January 2009 - 03:49 PM
Advertisements do not imply our endorsement of that product or service. The forum is run by volunteers who donate their time and expertise. We make every attempt to ensure that the help and advice posted is accurate and will not cause harm to your computer. However, we do not guarantee that they are accurate and they are to be used at your own risk.