Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 loop stops inserting !

Author  Topic 

jonas
Starting Member

6 Posts

Posted - 2008-06-24 : 07:43:09
for some reason my loop stops when i = 1 :s

						Statement s7 = MySql.connection.createStatement(); 
for(int i = 0; i < 50 ; i++) {
String test = "INSERT ignore INTO `testtable` (`name`,`Item"+i+"`,`Amount"+i+"`) values ('"+getUsername()+"','"+getItem(i)+"','"+getAmount(i)+"')";
s7.executeUpdate(test);
}


Can anyone help me please???

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-06-24 : 07:51:08
What does "ignore" do in the INSERT statement?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-06-24 : 07:51:54
String test = "INSERT INTO `testtable` (`name`,`Item`,`Amount`) values ('"+getUsername()+"','"+getItem(i)+"','"+getAmount(i)+"')";



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

jonas
Starting Member

6 Posts

Posted - 2008-06-24 : 08:28:16
i tried both, without result =/
and about this: didn't try yet:

String test = "INSERT INTO `testtable` (`name`,`Item`,`Amount`) values ('"+getUsername()+"','"+getItem(i)+"','"+getAmount(i)+"')";



i got in my table rows with item1 amount1 item2 amount2 item3amount3
so it wouldn't work? because u did `Item`,`Amount` without numbers ?

Jonas
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-06-24 : 08:36:22
Or try over dbforums.com since this is a mysql question.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-24 : 08:59:31
or try at www.mysql.com

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jonas
Starting Member

6 Posts

Posted - 2008-06-24 : 12:07:33
I still didn't found it
someone knows it? please tell mee
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-06-24 : 12:23:06
jonas, you've posted your question on a Microsoft SQL Server site. This is not a MySql site. You should post your question on a MySql site such as the ones already suggested to you.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -