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.
| Author |
Topic |
|
Tim
Starting Member
392 Posts |
Posted - 2003-04-29 : 22:36:23
|
I have a VB6 program that opens a connection to SQL2K using ADO and SQLOLEDB provider.In the database there's a table with a trigger that checks a constraint and returns an error like this:RAISERROR ('you messed up buddy',16,1)Back in VB, the ADO connection object's errors collection will show this in the cn.errors(0).description property.That's all great.I am running the application from Win2000 and in my regional settings I selected English (Australia). On SQL Server "select @@LANGUAGE" returns "us_english".If I change my regional settings to Dutch (Netherlands) the error is still generated but the cn.errors(0).description property is blank.I tried setting the locale identifier porperty of the ADO connection to match the language on the server, but it doesn't help.Any ideas?I am not sure if this is an ADO, OLEDB or SQL problem...EDIT - here example code for VBSub main()'** PROBLEM... (running on Win2000 pro)'** A trigger on a table in SQL7 SP2 returns an error msg using RAISEERROR.'** When a sql statement is sent from a VB6 program using an ADO (SQLOLEDB)'** connection the trigger raises an error, which is returned to the VB'** program via the Errors collection in the ADO connection object.'** Changing the locale in Window's regional options causes the error description'** to be returned as blank.'** Example: the description is returned for locale of English (United States)'** but not for Dutch (Netherlands)'** -- script to create the test table and trigger'** create table test'** ('** test int'** )'** GO'** CREATE TRIGGER trg_test ON [dbo].[test]'** FOR INSERT, UPDATE, DELETE'** AS'** RAISERROR ('test error message',16,1)'** GODim cn As New ADODB.ConnectionDim sql As String '// connect to db (CHANGE THE CONNECTION STRING AS REQUIRED cn.Open "Provider=sqloledb;Server=<SRV>;Database=<DB>;Trusted_Connection=Yes;" '// will fail because of insert trigger sql = "INSERT TEST (test) VALUES(1)" cn.Errors.Clear Err.Clear On Error GoTo ErrorHandler cn.Execute sql On Error GoTo 0 Exit SubErrorHandler: '// show the error details returned MsgBox CStr(cn.Errors(0).NativeError) + " - " + cn.Errors(0).Description cn.Close Set cn = NothingEnd SubEdited by - tim on 04/30/2003 02:34:45 |
|
|
simondeutsch
Aged Yak Warrior
547 Posts |
Posted - 2003-04-30 : 16:58:27
|
| BTW, are you expecting an English message, or a Dutch one?Sarah Berger MCSD |
 |
|
|
Tim
Starting Member
392 Posts |
Posted - 2003-04-30 : 19:27:41
|
| An English one, since I am using a literal for the message and not a msgid. In fact it is just a string of digits that I want returned, so language won't make much difference. EgRAISERROR ('1234',16,1) The applications uses this to look up the translated string in a resource file - our "gatekeepers" don't allow putting messages into SQL Server.I tried a msg anyway, that was just 50001 '%s'. It still comes up blank... |
 |
|
|
|
|
|
|
|