6
Answers

Problem :(

Hy! I have a really big problem. I want to insert some data into an Access database, and it all works when i have a small number of fields in it (like Name, Description, Weapon type etc.) but when i add some more fields to it my program start to fling syntax errors all over the place. I can't update the dataset with oledbcommandbuilder or anything. I checked the source to see if i messed something up but i think everythings in order. What i need is for someone to look at my program and tell me what i need to do to make it work :) Here's the program source: http://dhost.info/nwirongate/download/item_editor.rar

Answers (6)

0
Photo of nebojsa.pongracic
NA 12 0 20y
This could be helpfull for someone with similar problems: I used Value as a field name, and Value is some kind of a SQL or Access database reserved keyword so it didn't work. I simply changed the field name and now it works =)
0
Photo of nebojsa.pongracic
NA 12 0 20y
Thanks for your help ;) I couldn't find any error in my command text so i switched to Firebird, and now it works (plus my program runs faster :))
0
Photo of Andrzej Wegierski
NA 705 0 20y
Nearly sure You have ' character, null or invalid decimal sign in any of inserted fields - may be in Weight. Try to see Your CommandText under debugger or display it in MessageBox: MessageBox.Show(oleDbInsertCommand1.CommandText); 26 columns it's very little ... I use about 400 but in Oracle or MSSQL. I don't know about Firebird. Sorry, but I have no time to download Your application.
0
Photo of nebojsa.pongracic
NA 12 0 20y
The actual error is: Syntax error in INSERT INTO statement. Here is my command text: oleDbInsertCommand1.CommandText = "INSERT INTO Weapons([Damage Type], Description, Durability, [Maximum Damage], [Minimum Damage], Name, Picture, Range, Speed, Value, [Weapon Type], Weight) VALUES ('"+Creator.itmDamageType.Text+"', '"+Creator.itmDescription.Text+"', '"+Creator.itmDurability.Text+"', '"+Creator.itmMaxDamage.Text+"', '"+Creator.itmMinDamage.Text+"', '"+Creator.itmName.Text+"', '"+Creator.picPath.Text+"', '"+Creator.itmRange.Text+"', '"+Creator.itmSpeed.Text+"', '"+Creator.itmValue.Text+"', '"+Creator.itmTypeList.Text+"', '"+Creator.itmWeight.Text+"')"; If i insert 11 elements ([Damage Type], Description, Durability, [Maximum Damage], [Minimum Damage], Name, Picture, Range, Speed, [Weapon Type], Weight) into a datatable it works ok, but when i try to insert 12 or more elements like this: ([Damage Type], Description, Durability, [Maximum Damage], [Minimum Damage], Name, Picture, Range, Speed, Value, [Weapon Type], Weight) it reports the error. I need to have 26 data columns for item properties, but i cant :) Perhaps if i try to use some db other than Access .mdb database... Would Firebird .fdb database work? Anyway, if you still can't figure out what i'm trying to say (it's hard to explain, english is not my native language :)) download the program. It's around 400 kb in size ;)
0
Photo of Andrzej Wegierski
NA 705 0 20y
Would You mind to post error message and INSERT example? May be there are improper null or date formats or decimal separators? Use a space after commas in INSERTs etc. May be You have a data provider problem? Try to split Your DataTable into pieces with a little number of rows. How many columns are in the DataTable?
0
Photo of nebojsa.pongracic
NA 12 0 20y
I'm sorry i think i posted this in a wrong forum, it should be in ADO.Net technologies. Anyway, can someone move it? But to elaborate my problem: When you download the program you must do the following: Unrar it to some directory, open the ItemEditor.exe.config file and change connectionstring1 and connectionstring2 Data Source to point to your current directory with the items2h.mdb database in it (like c:\item editor\items2h.mdb) When you run the program make sure the Weapon tab is selected, click the first button on the toolbar (load items) and try to make some changes in the datagrid. When you click on the save button on the main form it doesn't do anything (it used to work). Then click Create and enter some values into the fields and try to click Save. It reports a syntax error in Insert INTO sql command, but as far as i can see there is NO syntax errors. Maybe i have too many DataColumns in the access database or something...