Using SQLXML, Bulk Insert XML with IDENTITY Column ...
I have a program that will insert xml data into a table using the SQLXML Bulk Load COM Object. The bulk load is successful when I supply the RecordId in the xml. When I add an IDENTITY column to the table then the bulk load fails with the following error:
[Cannot insert the value NULL into column 'RecordId', table 'Alphanumericdata.dbo.MacgowanTestCust'; column does not allow nulls. INSERT fails.]
From the following article, XML Bulk Load ignores elements and attributes that are not mapped (either because they are not described in the schema, or because they are annotated in the XSD schema with sql:mapped="false"). All unmapped data goes into the overflow column, if such a column is specified by using sql:overflow-field.
I have attempted using sql:mapped="false" in the schema file and not using it .. both fail with the “nulls not allowed” error.
I have also set the KeepIdentity(true) to my pISQLXMLBulkLoad object.
Below is the table, xml, xsd and code ...
Any comments or answers are appreciated.
CREATE TABLE [MacgowanTestCust] (
[RecordId] [int] IDENTITY (1, 1) NOT NULL ,
[CustomerID] [int] NOT NULL ,
[DataSourceId] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_MacgowanTestCust_DataSourceId] DEFAULT ('OH'),
[CompanyName] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[City] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
PRIMARY KEY CLUSTERED
) ON [PRIMARY]
) ON [PRIMARY]
// error message
<?xml version="1.0"?><Error><Record><HResult>0x80004005</HResult><SQLState>01000</SQLState><NativeError></NativeError><ErrorState>1</ErrorState><Severity>0</Severity><Source>Microsoft OLE DB Provider for SQL Server</Source><Description><![CDATA[The statement has been terminated.]]></Description></Record><Record><HResult>0x80004005</HResult><SQLState>23000</SQLState><NativeError></NativeError><ErrorState>2</ErrorState><Severity>16</Severity><Source>Microsoft OLE DB Provider for SQL Server</Source><Description><![CDATA[Cannot insert the value NULL into column 'RecordId', table 'Alphanumericdata.dbo.MacgowanTestCust'; column does not allow nulls. INSERT fails.]]></Description></Record></Error>
In my company, 4 users are accessing the sql server with a username and a password, they are developers, they have rights to create tables, fields, insert rows, deleting rows,...
how can I trace which computer make an insert or delete.
for example if a user make an insert into a table from SQL Server enterprise manager by writing an insert query, how can i know which computer make this action?
is that possible?
I have solved this problem in a different way. When the user logs in to the application, I insert the kerberos user id and the hostname in a Activity table. But there is a limitation. One user cannot start two instances of the application from the same host.
So when there is a update or delete or insert, I pick up the value from this table.
Everytime the user logs in, I clear the Activity for that user in a host machine.
CREATE PROCEDURE ValidateUser (
@userid varchar(10) )
DECLARE @cnt int
DELETE FROM Activity
WHERE Host = host_name()
INSERT INTO Activity VALUES(host_name(),@userid)
SELECT @cnt = count(*)
WHERE ID = @userid
IF @cnt = 1
In the trigger I do something like
IF @@rowcount = 0
SELECT @user = CurrentUser
WHERE Host = host_name()
INSERT INTO AuditTrail
SELECT @user,getdate(),'Table1','Column1' --blah blah
GetChanges() returns nothing here,
right after a row is deleted.
and there is actually 1 row removed from the dataset,
how is this possible?
dsCustomers.GetChanges() gives the same results.
Dim DataSetDeleted As DataSet = dsCustomers.GetChanges(DataRowState.Deleted)<br />
If Not DataSetDeleted Is Nothing Then<br />
From what i understand you need to call the delete method of the datarow.
Calling the remove method removes the row entirely (it is gone and the rowcount is reduced). When you call the getchanges method with the deleted parameter it looks for rows marked as deleted. as you have used remove there are no rows that fit this description. If you call the delete method it simply marks the row as deleted. GetChanges with then report that row as deleted and you can call an update.
you could have a look at my VisualCalc, even if it is mathematics oriented, but the general idea for writing a parser is still preserved. if you have any question on it, you can ask on the forum at the bottom of the article...
I'm trying to use RSA to protect incoming packets of data containing changed passwords.
My first idea was to use c# and the RSACryptoServiceProvider to generate the key information and to save the privatekeyinfo in a db table. The keys would then be replenished every x minutes. This seemed slightly wrong, as the private key info could be intercepted and used to impersonate a user changing the password.
I then discovered that there is a CREATE ASSYMETRIC KEY x_y_z WITH ALGORITHM RSA_x feature in SQL server. I have created the master keys and generated the key-pair, but i am at a loss as to how to retrieve the public key info so i can send it to the clients.
I have a small question concerning the use of ToWords() method that is embeded within Crystal Report.This function translates numeric values into their coresponding words value ex:150 --> One handred and fifty.
The problem I got is that I got an automatic english conversion of my numeric values where I need french corresponing string value. Is there any way I can swish it to french? Or how can I add my function, that does the french translation, to the crystal report embeded functions?
If anyone can help pls do.
to add your own function create a COM dll whose name starts with CRUFL and place it in the same directory as u2lcom.dll on your machine. Functions declared in the dll will now be available to crystal reports.
I have done this in the past using VB6 which created the dlls for me. Now that vb and c# 2005 express editors are available from MS free of charge i guess you could use these and generate interop assemblies to use with crystal.
i found this link on codeproject with a .net example
hi, and sorry again.
I followed the steps that are in the link and got some problems I couldn"t deal with. The first is that my DLL couldn't be registered within Windows. It says "No DLLRegisterServer Access point found"? I don't know what it means. The other problem is that within my project the "register for Com Interop is set to false but does not allow changes to true.
What I did is I created a new projet containing only the class needed to the translation an builded a new DLL named CRUFLctw.dll. Bt I 'm having the problem of Access point ??So the function still does not appear within formla staff in crystal report...
Please, I m really blocked and need your help
My guess here, and it's only a guess is that you have specified a windows application as the project output type. This is in the General section of the common properties tab. If you change the output type to Class library and then close and reopen the properties window (apply is not enough for some reason) You should be able to change the value of register for com interop.
BTW do you know that you will have to have the .net framework installed on any client that you want to run this function?
thanks for your answer,
I checked the project output it's set to class library. I think the problem comes from the fact that when trying to register the dll using regsvr32 it does not find DLLRegisterServer entry point. the msg I got is mydll.dll was correctly loaded But the DLLRegisterServer entry point was not found. Unable to register within windows. (I got the msg in french , I think this is the eng version.)
I didn't know that I'll need to have the .net framework installed on my clients
In my apllication, I read from 3 tables, I then make updates on the tables and then I read from them again, then I commit or roleback based on the information.
I want to make sure that from when I do the first read, that the database (or at least the 3 tables) is/are locked to that specific transaction. I do not want other clients to even read from the 3 table while the transaction is in progress.
I would like to know what Isolation Level is best for this?
You can write valid TSQL in different steps of your SQL jobs. In Enterprise Manager navigate to database server->Management->SQL Server Agent->Jobs and define a new backup job.
For example, I have a back up job defined in EM with one step having following code.
Declare @fileName nvarchar(250)
Set @fileName = N'C:\DBDailyBackup' + Replace(Replace(Replace(Convert(nvarchar(50), GetDate(), 20), ':', ''), ' ', ''), '-', '') + '.bak'
BACKUP DATABASE [pubs] TO DISK = @fileName WITH NOINIT , NOUNLOAD , NAME = N'pubs backup', NOSKIP , STATS = 10, NOFORMAT
You can also do it from Right click context menu on your database, choose All Tasks->Backup Database and define as schedule. Needless to say that you have to have SQL Agent service running for it to work properly.
Farhan Noor Qureshi
if (this == this) thow this;
Last Visit: 31-Dec-99 18:00 Last Update: 13-Aug-22 4:26