Neodudeman Posted June 17, 2008 Share Posted June 17, 2008 INSERT INTO Local_EPM_RETAIL ('AK',2001,1,23128.65,206108.43,11.22,20214.1,208499.68,9.7,6260.39,88762.7,7.05,2360.91,17664.85,13.36,51964.04,521035.66,9.97,'F'); I'm converting a VB.NET program into C#. The problem is it deals with SQL and Databases, and I have never really worked with them before. I'm haphazardly stepping through this shoddily written VB program with no documentation while trying to find C# equivalents of commands in VB.NET That I've never seen before. I've gotten through most of it, however; but one problem still plagues me. Whenever the program issues the ADODB.Connection.Execute(SQL, out objout, -1) command, (SQL Being the string "INSERT INTO Local_EPM_RETAIL ('AK',2001,1,23128.65,206108.43,11.22,20214.1,208499.68,9.7,6260.39,88762.7,7.05,2360.91,17664.85,13.36,51964.04,521035.66,9.97,'F');"), it gives me a Syntax error. I honestly don't know anything about what it's outputting, where it goes, what the table structure is, or anything at all really. All I know is, I was given this code, and I'm trying my best to fix it. If you could please help me, I would really appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/110570-whats-wrong-with-this-insert-into-statement/ Share on other sites More sharing options...
conker87 Posted June 17, 2008 Share Posted June 17, 2008 Try that: INSERT INTO Local_EPM_RETAIL VALUES('AK',2001,1,23128.65,206108.43,11.22,20214.1,208499.68,9.7,6260.39,88762.7,7.05,2360.91,17664.85,13.36,51964.04,521035.66,9.97,'F'); Quote Link to comment https://forums.phpfreaks.com/topic/110570-whats-wrong-with-this-insert-into-statement/#findComment-567244 Share on other sites More sharing options...
Neodudeman Posted June 17, 2008 Author Share Posted June 17, 2008 Wow, of course. That helped quite a bit! The program runs through a few INSERT INTO commands, but now it stops at this command: INSERT INTO Local_EPM_RETAIL VALUES('WY',2002,12,14832.97,220509.09,6.73,14717.68,262221.95,5.61,22155.57,621151.58,3.57,698.98,11148.68,6.27,52405.19,1115031.3,4.7,'F'); Works /\ Does NOT Work \/ INSERT INTO Local_EPM_RETAIL VALUES('AK',2003,1,24685.92,216630.13,11.4,22817.73,228658.18,9.98,7281.32,95592.2,7.62,,,,54784.97,540880.5,10.13,'F'); Could it be because of all the Commas, it errors? Quote Link to comment https://forums.phpfreaks.com/topic/110570-whats-wrong-with-this-insert-into-statement/#findComment-567252 Share on other sites More sharing options...
conker87 Posted June 17, 2008 Share Posted June 17, 2008 Hmm. Try adding 'NULL' to the values that don't have a value: INSERT INTO Local_EPM_RETAIL VALUES('AK',2003,1,24685.92,216630.13,11.4,22817.73,228658.18,9.98,7281.32,95592.2,7.62,NULL,NULL,NULL,54784.97,540880.5,10.13,'F'); Of course, it might be that these fields have had the 'NOT NULL' attribute added to them. Quote Link to comment https://forums.phpfreaks.com/topic/110570-whats-wrong-with-this-insert-into-statement/#findComment-567255 Share on other sites More sharing options...
webbiedave Posted June 17, 2008 Share Posted June 17, 2008 Both of those statements have exactly 18 comma separators so, without column names, you need to keep them. Try putting zeros or NULL's in the blank fields. I guess PHP in this thread stands for Pretty Helpful People Quote Link to comment https://forums.phpfreaks.com/topic/110570-whats-wrong-with-this-insert-into-statement/#findComment-567262 Share on other sites More sharing options...
Neodudeman Posted June 17, 2008 Author Share Posted June 17, 2008 Doh. Looking back at the original code, there is a line that says emptystring="NULL" In my naive coding wisdom, I copied instead: emptystring=null Thanks a lot for your help conker87, you just did in 5 minutes what I worked on for 5 hours yesterday! (Literally... =/) Pretty Helpful People, indeed. :-D Quote Link to comment https://forums.phpfreaks.com/topic/110570-whats-wrong-with-this-insert-into-statement/#findComment-567265 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.