|
|
SMS Server Tools 3 Community |
Welcome, Guest. The forum is currently read-only, but will open soon. |
Fri Apr 18, 2025 04:31 |
Login and Post Reply
Page: 1
Author |
Post |
|
#1 Sun Aug 26, 2012 22:15, 153 months ago.
|
Member
Registered: Jan 2010
Location: Bristol, United Kingdom
|
Windows 7 64Bit: 3.1.14: Smsd installed from: sources / package repository / from elsewhere... Huwei: USB: serial / USB / some adapter... Hi Keke, I'm trying to use the SQLCMD Utility to add and read records from an MS SQL Lite database. I can get it to work from the Cygwin command line but cannot get it to run from an SMSD script. If I Use this format directly in Cygwin it works no problem; sqlcmd -S .\\SQLEXPRESS -d SMS -Q "insert into parts (Part_No, Part_Description, Q_Description) VALUES ('4827771902','DVR','DVR')" Using the following in a script; sqlcmd -S .\\SQLEXPRESS -d SMS -Q "insert into parts (Part_No, Part_Description, Q_Description) VALUES ("'4827771988'","'DVRS'","'DVRS'")" Or this; sqlcmd -S .\\SQLEXPRESS -d SMS -Q "insert into parts (Part_No, Part_Description, Q_Description) VALUES (/"4827771988/",/"DVRS/",/"DVRS/")" Doesn't add any records. I am testing at the moment so the above is the only line in the script, which is called Test and I am running it directly from the cygwin command line. I'm sure there is a simple solution but cannot get there. Any ideas to help? Regards
|
|
#2 Sun Aug 26, 2012 22:58, 153 months ago.
|
Administrator
Registered: May 2009
Location: Jyväskylä, Finland
|
bill1798 wrote Or this; sqlcmd -S .\\SQLEXPRESS -d SMS -Q "insert into parts (Part_No, Part_Description, Q_Description) VALUES (/"4827771988/",/"DVRS/",/"DVRS/")"
It should work with backslashes: sqlcmd -S .\\SQLEXPRESS -d SMS -Q "insert into parts (Part_No, Part_Description, Q_Description) VALUES ( \"4827771988 \", \"DVRS \", \"DVRS \")" If it still does not work, what is the error message when you run it from the command line?
|
|
#3 Mon Aug 27, 2012 16:33, 153 months ago.
|
Member
Registered: Jan 2010
Location: Bristol, United Kingdom
Topic owner
|
Hello Keke, Thanks for your advice, it's been a while since I tackled the script language in SMS Tools so I am out of practice. As it turned out my Test program was not executable and so it wasn't doing anything once I resolved that then it didn't take too long to work out the correct syntax for SQL Lite. I have now changed my MYSMSD event handler to work with SQL and it seems to work well using the SQLCMD program. If it helps anyone else here is what the modified event handler looks like. As you can see SQL uses single quotes around the table column values and no / delimiters, it also doesn't like the ;"; at the end of the SQL strings preferring just a " . The SQL_ARGS string uses different switches from MYSQL but apart from that everything is pretty much the same. Regards Bill M
|
Login and Post Reply
Page: 1
Time in this board is UTC.
|
|
|
 |
|
 |
|