Wahoo! I owe you a beer :-)
That did the trick. Its inserted into the Database quite happily. I think I'll need to use both that and a filter for apostrophes in the future to make 100% sure I dont get anything untoward passed to the ODBC driver. Many thanks to everyone who replied to me, your help was much appreciated. Kind Regards Ross Dutrieux Yves <[EMAIL PROTECTED]> on 28/01/2003 11:07:32 To: Ross Draper/Radio@Radio, Dutrieux Yves <[EMAIL PROTECTED]> cc: Subject: RE: Win32 ODBC and SQL Insert error. Try this with your original code, $BIOSVer=~s/\00//g; before the INSERT I've seen that $BIOSVer is a binary value in registry and at the end of value, there are two Binary Nul (\00). With this code, the binary value are fired. Yves -----Original Message----- From: Ross Draper [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 28, 2003 11:01 AM To: Dutrieux Yves Subject: RE: Win32 ODBC and SQL Insert error. Hi Dutrieux Thanks for your help. I've tried as you sugested, but still get the error. Do you know of any regular expression that would filter out non printing characters? I'm not quite sure what you mean by debug and display, If by that you simply mean printing the value to screen, I have done so and the variable is correct before and after the SQL insert. Kind Regards Ross Dutrieux Yves <[EMAIL PROTECTED]> on 28/01/2003 07:56:49 To: Ross Draper/Radio@Radio cc: [EMAIL PROTECTED], Timothy Johnson <[EMAIL PROTECTED]> Subject: RE: Win32 ODBC and SQL Insert error. REG_MULTI_SZ are array ... so I think you have some nul values in your reference array $BIOSVer Can you debug and display $BIOSVer to see if it's correct ? try this ? ($BIOVer)= $BIOSKey->GetValue('SystemBiosVersion'); Here a old message that explain : === cut ===== "Lee Clemmer" <[EMAIL PROTECTED]> writes: > $retval = $key->SetValue("TurfTable", @junklist, "REG_MULTI_SZ" Executive summary: Try \@junklist instead. > I JUST tried this with the syntax shown in the example > ("valuename",["foo.com","bar.com", "bax.com"],"REG_MULTI_SZ") > What is the difference between my named array and an anonymous one?! Perl arrays have "splicing semantics", which are very useful. But they are definitely confusing if you are accustomed to other languages. (The closest thing in C is probably varargs, which is not very close. Even Lisp requires you to use things with names like "quasiquote" and "unquote-splicing" and "eval" and "apply" to get similar semantics.) In short, this code: my @foo = (1, 2, 3); bar (@foo); ...does the same thing as this code: bar (1, 2, 3); Both call "bar" with three arguments: the numbers 1, 2, and 3. Contrast with this: my @foo = (1, 2, 3); bar (\@foo); ...which is the same as: bar ([1, 2, 3]); These both call "bar" with one argument, a reference to an array containing the numbers 1, 2, and 3. The square brackets create a reference to an (anonymous) array. To obtain a reference to a named array, you put a backslash before the name, like so: $retval = $key->SetValue("TurfTable", \@junklist, "REG_MULTI_SZ"); - Pat _______________________________________________ Perl-Win32-Admin mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs == cut ==== -----Original Message----- From: Ross Draper [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 28, 2003 2:07 AM To: Timothy Johnson Cc: [EMAIL PROTECTED] Subject: RE: Win32 ODBC and SQL Insert error. Hi Tim Thanks for your reply. Yup, I've tried escaping the backslashes, I just removed them in the last mail for readability. I'm currently going on the theory that I am getting a hidden character from the REG_MULTI_SZ string in the registry. When you goto modify the value from regedt32 it lists the binary value of it in addition to the text so I am assuming I am getting some sort of hidden character left over from the conversion process Perl is putting it through. When printed to screen or a text file it looks fine. Does this sound plausible? Cheers Ross Timothy Johnson <[EMAIL PROTECTED]> on 01/28/2003 01:05:10 To: Ross Draper/Radio@Radio, [EMAIL PROTECTED] cc: Subject: RE: Win32 ODBC and SQL Insert error. Have you tried "HKEY_LOCAL_MACHINE\\Hardware\\Description\\System\\SystemBiosVersion"? -----Original Message----- From: Ross Draper [mailto:[EMAIL PROTECTED]] Sent: Monday, January 27, 2003 4:29 PM To: [EMAIL PROTECTED] Subject: RE: Win32 ODBC and SQL Insert error. I've done some additional info and found that I can import settings from other portions of the registry with no problems. It only appears to be this one value: "HKEY_LOCAL-MACHINEL\Hardware\Description\System\SystemBiosVersion " that is causing the problem. Its type is REG_MULTI_SZ. Can anybody think as to why this one setting would cause problems when fetched with TieRegistry and used in conjuntion with Win32 ODBC ? There dont seem to be any SQL delimeters in the values I'm returning, I'm at a complete loss! Thanks for your help. Kind Regards Ross ---------------------- Forwarded by Ross Draper/Radio on 01/28/2003 00:41 --------------------------- Ross Draper 01/27/2003 23:23 To: [EMAIL PROTECTED] cc: Subject: Win32 ODBC and SQL Insert error. Hi guys I've been puzzling over this for a little while now and could do with some help. I've written a script to retrieve information from remote NT/2000 machines and squirt it into a MS SQL database(2000) for the purposes of auditing. Everything was working fine until a week or so ago when I noticed that some machines werent appearing in my db anymore. After doing some debugging I have found that my SQL insert statement is failing with the following error: Error: [105] [1] "[Microsoft][ODBC SQL Server Driver][SQL Server]Unclosed quotation mark before the character string 'Phoenix ROM BIOS PLUS Version 1.10 A15'." To get to the basics of the problem I chucked away half the script and whittled it down to just the sections that retrieve and then insert the data. It seems that no matter what I do I keep getting this error and I think I have spent so long looking at it that I can no longer do so objectively. --------------------------------------------- use Win32::TieRegistry; use Win32::ODBC; $IPaddress = "127.0.0.1"; if (!($db = new Win32::ODBC("DSN=auditdb;UID=xxxxx;PWD=xxxxxx;"))){ print "Error connecting to $dsn\n"; print "please check the settings in your ini file and try again.\n"; print "Error: " . Win32::ODBC::Error() . "\n"; exit; } else { print "->Successfully connected to database using dsn.\n" } $BIOSKey =new Win32::TieRegistry"\\\\$IPaddress\\LMachine\\Hardware\\Description\\System\\ "; $BIOSVer = $BIOSKey->GetValue('SystemBiosVersion'); $db->Sql("INSERT INTO audit.dbo.system VALUES ( '$BIOSVer', 'testPC' ) " ); print "below is insert error\n"; print "Error: " . Win32::ODBC::Error() . "\n"; $db->Close; -------------------------------------------------- Can you notice anything wrong with the above that could cause it to generate the SQL error? The whole insert sting is just a series of variables in the full program. To my knowledge the SQL server hasnt been touched and I have double and triple checked the db design. If i substitute a text string for the variable it all works fine, so I can only assume I am picking up a hidden character from somewhere? Could somebody be kind enough to put me out of my misery and point out how I have caused this error? This is running on win2k Pro and perl v5.6.1. Many thanks Ross ************************************************************************* GWR on the Web http://www.koko.com http://www.classicfm.com http://www.corefreshhits.com http://www.planetrock.com http://www.opusonline.co.uk http://www.gwrgroup.com CONFIDENTIALITY NOTICE The information in this e-mail and any attachments to it is confidential and may be legally privileged or prohibited from disclosure and unauthorised use. If you are not the intended recipient, any use, copying, disclosure, modification, distribution and/or publication of this message or its attachments (if any) is prohibited and may be unlawful. We will not accept liability for any claims arising as a result of the use of the internet to transmit information by or to GWR Group plc. **************************************************************************** *********************** _______________________________________________ Perl-Win32-Admin mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ Perl-Win32-Admin mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ Perl-Win32-Admin mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
