Showing posts with label write. Show all posts
Showing posts with label write. Show all posts

Thursday, March 29, 2012

Error when updating bigint columns using ADO

I am attempting to write a conversion of our product for Compact Edition; we already provide it based on SQL Server. The database interface uses ADO through a Python-win32com adaptor, and has worked fine so far. (Note: *not* ADO.net, just plain old COM)

Now, a curious thing happens. When inserting new data through a Recordset, everything works fine - except for columns defined as bigint. There are no exceptions thrown, but when you read the columns back they contain nothing but zeroes. Do the same to any other column type - I've tried integer, numeric, float, nvarchar and ntext so far, and they all seem to work just fine. It does not seem to be conversion-related either, since I've tested the exact same data to various column types. And using bigint on regular SQL Server works just fine.

The code involved is quite unspectacular, and simply switching the column types to integer would solve the immediate problem, but causes potential future issues since we normally store internal IDs in bigint columns, and the values may grow quite large.
This may indicate a problem with compatibility betweeen the 3rd party python ADO adaptor and the SQL CE OLEDB provider.

Error when trying to save or write to table

Hi,
I am doing a tuning exercise on a SQL 2K5 instance, I am encountering
a problem when Profiler goes to create a table. I have profiled
Profiler and have extracted the following code
CREATE TABLE [dbo].[con1] ([RowNumber] int IDENTITY(0,1) PRIMARY KEY,
[EventClass] int NULL,[Duration] bigint NULL,,
[TextData] ntext NULL,[SPID] int NULL,[BinaryData] image NULL,[CPU]
int NULL,[Reads] bigint NULL,[Writes] bigint NULL,[ApplicationName]
nvarchar(128) NULL,[ClientProcessID] int NULL,[DatabaseID] int NULL,
[DatabaseName] nvarchar(128) NULL,[EventSequence] int NULL,
[EventSubClass] int NULL,[HostName] nvarchar(128) NULL,[IntegerData]
int NULL,[IsSystem] int NULL,[LoginName] nvarchar(128) NULL,[LoginSid]
image NULL,[NTDomainName] nvarchar(128) NULL,[NTUserName]
nvarchar(128) NULL,[RequestID] int NULL,[ServerName] nvarchar(128)
NULL,[SessionLoginName] nvarchar(128) NULL,[StartTime] datetime NULL,
[TransactionID] bigint NULL)
As you can see, after Duration (the 3rd column), there is a double
comma inserted which of course is erroring.
This occurs when defining a table to save to prior to running the
trace, and defining a table after running the trace.
I have tried the standard profiler which appears to work fine.
I also updated to SP2 CTP (this is a test server) because it appeared
to be an issue simular to this http://support.microsoft.com/?
kbid=925335.
A quick response would be appreciated as I am a contractor and I am on
tight timescales.
Cheers
Steve
Steve,
I don't know how to fix the error with profiler but I recommend you not do
that in the fist place. Tracing to a table can be a huge performance hit and
can skew your results. It is recommended that you trace directly to a file
using sp_trace_create and then use fn_trace_gettable to retrieve the data.
You can do something like this to put the trace results in a table:
SELECT * INTO YourTable FROM fn_trace_gettable(xxx)
If you already have a trace in profiler you can save it to a file and do the
same.
Andrew J. Kelly SQL MVP
"Steve L" <steve_lawrenson@.tiscali.co.uk> wrote in message
news:1170411376.241148.280690@.v33g2000cwv.googlegr oups.com...
> Hi,
> I am doing a tuning exercise on a SQL 2K5 instance, I am encountering
> a problem when Profiler goes to create a table. I have profiled
> Profiler and have extracted the following code
> CREATE TABLE [dbo].[con1] ([RowNumber] int IDENTITY(0,1) PRIMARY KEY,
> [EventClass] int NULL,[Duration] bigint NULL,,
> [TextData] ntext NULL,[SPID] int NULL,[BinaryData] image NULL,[CPU]
> int NULL,[Reads] bigint NULL,[Writes] bigint NULL,[ApplicationName]
> nvarchar(128) NULL,[ClientProcessID] int NULL,[DatabaseID] int NULL,
> [DatabaseName] nvarchar(128) NULL,[EventSequence] int NULL,
> [EventSubClass] int NULL,[HostName] nvarchar(128) NULL,[IntegerData]
> int NULL,[IsSystem] int NULL,[LoginName] nvarchar(128) NULL,[LoginSid]
> image NULL,[NTDomainName] nvarchar(128) NULL,[NTUserName]
> nvarchar(128) NULL,[RequestID] int NULL,[ServerName] nvarchar(128)
> NULL,[SessionLoginName] nvarchar(128) NULL,[StartTime] datetime NULL,
> [TransactionID] bigint NULL)
> As you can see, after Duration (the 3rd column), there is a double
> comma inserted which of course is erroring.
> This occurs when defining a table to save to prior to running the
> trace, and defining a table after running the trace.
> I have tried the standard profiler which appears to work fine.
> I also updated to SP2 CTP (this is a test server) because it appeared
> to be an issue simular to this http://support.microsoft.com/?
> kbid=925335.
> A quick response would be appreciated as I am a contractor and I am on
> tight timescales.
> Cheers
> Steve
>
|||On 2 Feb, 14:11, "Andrew J. Kelly" <sqlmvpnooos...@.shadhawk.com>
wrote:
> Steve,
> I don't know how to fix the error with profiler but I recommend you not do
> that in the fist place. Tracing to a table can be a huge performance hit and
> can skew your results. It is recommended that you trace directly to a file
> using sp_trace_create and then use fn_trace_gettable to retrieve the data.
> You can do something like this to put the trace results in a table:
> SELECT * INTO YourTable FROM fn_trace_gettable(xxx)
> If you already have a trace in profiler you can save it to a file and do the
> same.
> --
> Andrew J. Kelly SQL MVP
> "Steve L" <steve_lawren...@.tiscali.co.uk> wrote in message
> news:1170411376.241148.280690@.v33g2000cwv.googlegr oups.com...
>
>
>
>
>
>
> - Show quoted text -
Hi Andrew
thanks for the response, I will use the method above as a workaround
and thanks for that information. It would be nice to know if this is a
recognised issue by MS and what their recommended workarounds are for
it.
Cheers
Steve L

Sunday, February 26, 2012

Error trying to write file

I don't have direct access to the SQL server. I have to write/read through a class I recieved from the IT department. The class also had an example in it but I can't get it to work correctly.

I get an error: Object reference not set to an instance of an object. Line 35


Dim clsWDD As New WebDevDB.WebDevDB
Dim intLeng As Int32
Dim intLock As Int32

Dim strAppl As String = "MyApplication"
Dim strData As String = "This is my text data!"

Dim strFile As String = "MyFile"

intLock = clsWDD.LockTextFile(strAppl, strFile) 'line 35
intLeng = clsWDD.WriteTextFile(strAppl, strFile, strData, WriteAction.Create)
intLock = clsWDD.UnlockTextFile(intLock)

What does the whole exception.tostring say?|||Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 33: Dim strFile As String = "MyFile"
Line 34:
Line 35: intLock = clsWDD.LockTextFile(strAppl, strFile)
Line 36: intLeng = clsWDD.WriteTextFile(strAppl, strFile, strData, WriteAction.Create)
Line 37: intLock = clsWDD.UnlockTextFile(intLock)

Source File: C:\Inetpub\wwwroot\TestSolution\WebForm1.aspx.vb Line: 35

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
WebDevDB.WebDevDB.GetConnectionString()
WebDevDB.WebDevDB.LockTextFile(String ApplicationName, String FileName, Byte LockSeconds, Byte LockAttempts)
TestSolution.WebForm1.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\TestSolution\WebForm1.aspx.vb:35
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

Friday, February 17, 2012

Error severity

Hi,
I want to write this SQL script
--
create table table1(
ID_TABLE1 varchar(15) not null
constraint PK_TABLE1 primary key clustered
(ID_TABLE1)
)
IF @.@.ERROR <> 0
BEGIN
print 'Error create table1'
END
--
The problem is when there is a 'create error', the code
print 'Error ...' is not executed because the error's
severity is too high and the script stops.
Is it possible to trap the default error ? When there is a
create error, I want that's the @.@.error is initialized and
the test is executed.
Thanks in advance for your help
Antoine (F-Paris)
MSSQL 7 & MSSQL 2000If the error is severe enough it will stop the batch and you can not trap it
within the batch. You would have to check for the error where you call the
batch. If your using something like ADO, sql server will report an error
that you can see in the errors collection.
Andrew J. Kelly
SQL Server MVP
"Antoine C." <acazedev@.libertysurfXXX.fr> wrote in message
news:11da01c3df60$d4f02bf0$a401280a@.phx.gbl...
quote:

> Hi,
> I want to write this SQL script
> --
> create table table1(
> ID_TABLE1 varchar(15) not null
> constraint PK_TABLE1 primary key clustered
> (ID_TABLE1)
> )
> IF @.@.ERROR <> 0
> BEGIN
> print 'Error create table1'
> END
> --
> The problem is when there is a 'create error', the code
> print 'Error ...' is not executed because the error's
> severity is too high and the script stops.
> Is it possible to trap the default error ? When there is a
> create error, I want that's the @.@.error is initialized and
> the test is executed.
> Thanks in advance for your help
> Antoine (F-Paris)
> MSSQL 7 & MSSQL 2000
|||
quote:

>--Original Message--
>If the error is severe enough it will stop the batch
> and you can not trap itwithin the batch.
> You would have to check for the error where you call the
>batch.
>--

Thank you for the quick answer Andrew.
Bye