Showing posts with label commands. Show all posts
Showing posts with label commands. Show all posts

Wednesday, March 7, 2012

Error [1,133,:] What does this mean

Hello,

on a WinCE5.0 device I run the following commands - (not complete):

DataSet oDS;

DataTable oDT=null;

// fill oDS from Web-Service ...

localhost.ODPService _wsTemp = _MAPD.GetWebService();

oDS = _wsTemp.GetAllZaehler();

string sConn = null;

//SqlCeEngine engine = null;

System.Data.SqlServerCe.SqlCeConnection oConn=null;

if (File.Exists(_MAPD.ExePfad + "MACOS_mo_db.sdf"))

{

sConn = "data source ='" + @._MAPD.ExePfad + "MACOS_mo_db.sdf'; mode=Exclusive; Password='xxxx'";

oConn = newSqlCeConnection(sConn);

if (oConn == null)

thrownewException("SQL-Connection zu " + @._MAPD.ExePfad + "MACOS_mo_db.sdf? konnte nicht erstellt werden!");

...

oConn.Open();

SqlCeCommand oCmd = newSqlCeCommand();

oCmd.Connection = oConn;

oCmd.CommandText = "DELETE from mo_OB_ZAEHLER";

oCmd.ExecuteNonQuery(); // This works !!

oCmd.Dispose();

oCmd = newSqlCeCommand();

oCmd.Connection = oConn;

string sStmt = "INSERT into mo_OB_ZAEHLER( OBJEKT_GUID, IDENT_NR, KURZ_TIT, OB_BEZ, EINHEIT, DATUM_ALT, STAND_ALT, ABGEHOLT, GESCHRIEBEN ) values ( :1, :2, :3, :4, :5, :6, :7, :8, :9 )";

oCmd.CommandText = sStmt;

oDT = oDS.Tables[0];

SqlCeParameter oP1 = newSqlCeParameter();

SqlCeParameter oP2 = newSqlCeParameter();

SqlCeParameter oP3 = newSqlCeParameter();

SqlCeParameter oP4 = newSqlCeParameter();

SqlCeParameter oP5 = newSqlCeParameter();

SqlCeParameter oP6 = newSqlCeParameter();

SqlCeParameter oP7 = newSqlCeParameter();

SqlCeParameter oP8 = newSqlCeParameter();

SqlCeParameter oP9 = newSqlCeParameter();

oP1.ParameterName = ":1";

oP2.ParameterName = ":2";

oP3.ParameterName = ":3";

oP4.ParameterName = ":4";

oP5.ParameterName = ":5";

oP6.ParameterName = ":6";

oP7.ParameterName = ":7";

oP8.ParameterName = ":8";

oP9.ParameterName = ":9";

oCmd.Parameters.Add(oP1);

oCmd.Parameters.Add(oP2);

oCmd.Parameters.Add(oP3);

oCmd.Parameters.Add(oP4);

oCmd.Parameters.Add(oP5);

oCmd.Parameters.Add(oP6);

oCmd.Parameters.Add(oP7);

oCmd.Parameters.Add(oP8);

oCmd.Parameters.Add(oP9);

DateTime oNow = newDateTime();

oNow = DateTime.Now;

for (int iRow = 0; iRow < oDT.Rows.Count; iRow++)

{

oCmd.Parameters[0].Value = oDT.Rows[iRow]["OBJEKT_GUID"];

oCmd.Parameters[1].Value = oDT.Rows[iRow]["IDENT_NR"];

oCmd.Parameters[2].Value = oDT.Rows[iRow]["KURZ_TIT"];

oCmd.Parameters[3].Value = oDT.Rows[iRow]["OB_BEZ"];

oCmd.Parameters[4].Value = oDT.Rows[iRow]["EINHEIT"];

oCmd.Parameters[5].Value = oDT.Rows[iRow]["DATUM_ALT"];

oCmd.ParametersDevil.Value = oDT.Rows[iRow]["STAND_ALT"];

oCmd.Parameters[7].Value = oNow;

oCmd.ParametersMusic.Value = (int)0;

oCmd.ExecuteNonQuery();

}

....

at oCmd.ExecuteNonQuery() - line after oCmd.ParametersMusic.Value =... - an error with Message " [ 1,133,: ]" is thrown.

What does this mean?
Where can I find discription of error codes? Why is there no further text in the Exception object?

I checked the parameters set in oCmd and they seem to be correct.

Please help.

J?rg

The error indicates a SQL parsing error at character 133. Change your parameter names from :1 to @.1 (and so on).

For information on how to get detailed SQL CE error information, see: http://msdn2.microsoft.com/en-us/library/ms174079(SQL.90).aspx

Friday, February 24, 2012

Error - Trancount Reset!

Hi,
I am using the T-SQL commands "BEGIN TRANSACTION", "COMMIT TRANSACTION"
and "ROLLBACK TRANSACTION" via the Statement.Execute method instead of
setting the autoCommit feature of JDBC.
We often have objects that contain transactional updates that may be called
by another object that has already initiated a transaction or that may be
used alone, thus we need a form of transaction nesting which the autoCommit
feature does not provide.
However, we have noticed that the @.@.TRANCOUNT will reset to 0 once a
statement object is created on the same connection - for example, we would
expect:
FIRST OBJECT
BEGIN TRANSACTION
... SOME WORK (TRANCOUNT = 1)
SECOND OBJECT
BEGIN TRANSACTION (TRANCOUNT = 2)
.. SOME WORK
COMMIT TRANSACTION (TRANCOUNT = 1)
FIRST OBJECT
COMMIT TRANSACTION (TRANCOUNT = 0)
However, we have noticed that as soon as a Statement object is created in
the inner transaction, the TRANCOUNT is immediately set to 0. Then, when the
COMMIT TRANSACTION statement is issued, an error is raised because there is
no matching BEGIN TRANSACTION.
Has anyone ever encountered this error? Is it a bug?
Thanks,
Mike
MikeF wrote:

> Hi,
> I am using the T-SQL commands "BEGIN TRANSACTION", "COMMIT TRANSACTION"
> and "ROLLBACK TRANSACTION" via the Statement.Execute method instead of
> setting the autoCommit feature of JDBC.
Very dangerous.

> We often have objects that contain transactional updates that may be called
> by another object that has already initiated a transaction or that may be
> used alone, thus we need a form of transaction nesting which the autoCommit
> feature does not provide.
That doesn't explain why the autoCommit() path won't work. You set autoCommit(false)
and call what you want. anything below needn't know whether it's in a tx or not.
Then commit or roll back.

> However, we have noticed that the @.@.TRANCOUNT will reset to 0 once a
> statement object is created on the same connection - for example, we would
> expect:
> FIRST OBJECT
> BEGIN TRANSACTION
> ... SOME WORK (TRANCOUNT = 1)
> SECOND OBJECT
> BEGIN TRANSACTION (TRANCOUNT = 2)
> .. SOME WORK
> COMMIT TRANSACTION (TRANCOUNT = 1)
> FIRST OBJECT
> COMMIT TRANSACTION (TRANCOUNT = 0)
> However, we have noticed that as soon as a Statement object is created in
> the inner transaction, the TRANCOUNT is immediately set to 0. Then, when the
> COMMIT TRANSACTION statement is issued, an error is raised because there is
> no matching BEGIN TRANSACTION.
> Has anyone ever encountered this error? Is it a bug?
You need to add a connection property selectMethod=cursor. Otherwise
the driver will make *new connections* under the covers to implement
concurrent statements, and each statement will be independent of
the connection/statement on which you think you started a transaction.
This would have been prevented/revealed immediately if you had stuck to
JDBC control calls for defining your transactions.
Joe Weinstein at BEA
> Thanks,
> Mike

Friday, February 17, 2012

Error

I used the following commands but it gave me following error:
EXEC sp_addlinkedserver dbf ,'Jet 4.0'
, 'Microsoft.Jet.OLEDB.4.0'
, 'D:\'
, NULL
, 'dBASE III'
GO
EXEC sp_addlinkedsrvlogin 'dbf', 'false', NULL, 'sa', 'mypassword'
SELECT TOP 10 * FROM dbf...doctor
************************************************
Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error. Authentication
failed.
[OLE/DB provider returned message: Cannot start your application. The
workgroup information file is missing or opened exclusively by another
user.]
OLE DB error trace [OLE/DB Provider 'Microsoft.Jet.OLEDB.4.0'
IDBInitialize::Initialize returned 0x80040e4d: Authentication failed.].
************************************************
There is one doctor.dbf file in d: drive.
Waiting for your reply
Noor
If you're going against the Jet provider, the login is 'Admin' with a
blank password ('').
--Mary
On Tue, 30 Mar 2004 09:38:14 +0500, "Noorali Issani"
<naissani@.softhome.net> wrote:

>I used the following commands but it gave me following error:
>EXEC sp_addlinkedserver dbf ,'Jet 4.0'
> , 'Microsoft.Jet.OLEDB.4.0'
> , 'D:\'
> , NULL
> , 'dBASE III'
>GO
>EXEC sp_addlinkedsrvlogin 'dbf', 'false', NULL, 'sa', 'mypassword'
>
>SELECT TOP 10 * FROM dbf...doctor
>*********************************************** *
>Server: Msg 7399, Level 16, State 1, Line 1
>OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error. Authentication
>failed.
>[OLE/DB provider returned message: Cannot start your application. The
>workgroup information file is missing or opened exclusively by another
>user.]
>OLE DB error trace [OLE/DB Provider 'Microsoft.Jet.OLEDB.4.0'
>IDBInitialize::Initialize returned 0x80040e4d: Authentication failed.].
>*********************************************** *
>There is one doctor.dbf file in d: drive.
>Waiting for your reply
>Noor
>

Wednesday, February 15, 2012

Erro trapping question

I have a batch file that runs SQL Server scripts using commands like:

OSQL -Umyname -Pmypassword -iScript_01.sql -w200 -e -n
>>Consolidation.log

Script_01.sql will contain statements like:
Update SASI.AACT set schoolnum='071' where schoolnum in ('000',' ')
update SASI.AATD set schoolnum='071' where schoolnum in ('000',' ')
update SASI.AATP set schoolnum='071' where schoolnum in ('000',' ')
update SASI.ACHS set schoolnum='071' where schoolnum in ('000',' ')
update SASI.ACLS set schoolnum='071' where schoolnum in ('000',' ')

If one of those tables should not exist, how could I have it continue,
but hopefully the log would have a reference to the error?

I am experimenting, but I am unsuccessfull with something like:
BEGIN TRAN
select count(*) from sasi.aact --this could be an update
statement
if @.@.ERROR =208 GOTO err_handle
select count(*) from sasi.astu
if @.@.ERROR <> 0 GOTO err_handle
select count(*) from sasi.astu
if @.@.ERROR <> 0 GOTO err_handle
select count(*) from sasi.astu
if @.@.ERROR <> 0 GOTO err_handle
err_handle:
return
commit Tran<OakRogbak_erPine@.yahoo.com> wrote in message
news:13fdc9b4.0410140645.305d53d3@.posting.google.c om...
>I have a batch file that runs SQL Server scripts using commands like:
> OSQL -Umyname -Pmypassword -iScript_01.sql -w200 -e -n
>>>Consolidation.log
> Script_01.sql will contain statements like:
> Update SASI.AACT set schoolnum='071' where schoolnum in ('000',' ')
> update SASI.AATD set schoolnum='071' where schoolnum in ('000',' ')
> update SASI.AATP set schoolnum='071' where schoolnum in ('000',' ')
> update SASI.ACHS set schoolnum='071' where schoolnum in ('000',' ')
> update SASI.ACLS set schoolnum='071' where schoolnum in ('000',' ')
> If one of those tables should not exist, how could I have it continue,
> but hopefully the log would have a reference to the error?
> I am experimenting, but I am unsuccessfull with something like:
> BEGIN TRAN
> select count(*) from sasi.aact --this could be an update
> statement
> if @.@.ERROR =208 GOTO err_handle
> select count(*) from sasi.astu
> if @.@.ERROR <> 0 GOTO err_handle
> select count(*) from sasi.astu
> if @.@.ERROR <> 0 GOTO err_handle
> select count(*) from sasi.astu
> if @.@.ERROR <> 0 GOTO err_handle
> err_handle:
> return
> commit Tran

Error handling is rather awkward in MSSQL:

http://www.sommarskog.se/error-handling-I.html
http://www.sommarskog.se/error-handling-II.html

In your case, the easiest thing is probably to avoid the error by checking
if the table exists before trying to query it:

if object_id('sasi.aact') is not null and
objectproperty(object_id('sasi.aact'), 'IsTable') = 1
begin
... -- do something here
end
else
begin
... -- log to an error table
end

Simon