473,407 Members | 2,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Trouble passing XML string to OpenXML SPROC

a
I'm trying to pass an xml file as a variable of type string to an OpenXML
stored procedure, but the code below fails at the "sCmd01.ExecuteNonQuery();"
line. The SPROC is working fine in Query Analyzer.

Anyone know how to make this work?

Thanks,

Paul

the error code is:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred
in system.data.dll

Additional information: System error.
===========================================

string XMLDoc = "D:\\SEC\\Programming\\SEC DataBots\\SEC DataBot Test
Files\\Form 4\\From QS.xml";
StreamReader srXML = new StreamReader(XMLDoc);
string xmlDoc = srXML.ReadToEnd();
SqlConnection sCon01 = new
SqlConnection("server=AMD;Trusted_Connection=yes;d atabase=MyDatabase");
SqlCommand sCmd01 = new
SqlCommand("_sp_Insert_Form_004_XML_template_07",s Con01);
sCmd01.CommandType = CommandType.StoredProcedure;
sCmd01.Parameters.Add("@Form_004",SqlDbType.NText) .Value = xmlDoc;
sCmd01.Connection.Open();
sCmd01.ExecuteNonQuery();
sCmd01.Connection.Close();

Nov 17 '05 #1
1 2637
a
OK...I didn't validate the test document...it turns out to have an error in it.
The code I've been using is actually ok--except that it needs to also
validate the files.

Paul
---------------------------------------------------------------

"a" wrote:
I'm trying to pass an xml file as a variable of type string to an OpenXML
stored procedure, but the code below fails at the "sCmd01.ExecuteNonQuery();"
line. The SPROC is working fine in Query Analyzer.

Anyone know how to make this work?

Thanks,

Paul

the error code is:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred
in system.data.dll

Additional information: System error.
===========================================

string XMLDoc = "D:\\SEC\\Programming\\SEC DataBots\\SEC DataBot Test
Files\\Form 4\\From QS.xml";
StreamReader srXML = new StreamReader(XMLDoc);
string xmlDoc = srXML.ReadToEnd();
SqlConnection sCon01 = new
SqlConnection("server=AMD;Trusted_Connection=yes;d atabase=MyDatabase");
SqlCommand sCmd01 = new
SqlCommand("_sp_Insert_Form_004_XML_template_07",s Con01);
sCmd01.CommandType = CommandType.StoredProcedure;
sCmd01.Parameters.Add("@Form_004",SqlDbType.NText) .Value = xmlDoc;
sCmd01.Connection.Open();
sCmd01.ExecuteNonQuery();
sCmd01.Connection.Close();

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: mirza i | last post by:
in asp i have this line: ..... Set paramsx = cmdUpdatex.CreateParameter ("@invdate", addate, adParamInput, 50, invdate) cmdUpdatex.Parameters.Append paramsx ... (the invdate value is a...
4
by: Driesen via SQLMonster.com | last post by:
Hi guys I having trouble with this sproc. I get the following error when testing: Server: Msg 245, Level 16, State 1, Procedure UTL_CompletenessCheckLoan, Line 231 Syntax error converting the...
2
by: Bob | last post by:
I'm new to Access projects and SQL server and am not a veteran VB programmer. There's a cry for help! I'm attempting to print the current form on screen by using a command button which the user...
1
by: John Hoge | last post by:
Is it possible to pass a null value to a stored procedure in .net? I have a search Sproc that can take one of two numbers to search on, but not both. I use the code below to pass a null value to...
4
by: Chad Micheal Lawson via .NET 247 | last post by:
I'm stumped at this point and I'm tired of trying things so I'mposting in hopes of some guru with a sharp eye. I have anasp.net app running on a local Win XP Pro box. Within the app,I call a SPROC...
0
by: Micke | last post by:
On a code behing page to an aspx page I want to open a xml file in Excel and save it as an Excel file. I have following code that is working: Dim oExcel As New Excel.Application Dim oBook As...
5
by: Tim::.. | last post by:
Can someone please tell me if it is possible to get the SQL statement from a stored procedure in ASP.NET? Dim Myconn As New SqlConnection(ConfigurationSettings.AppSettings("strConn")) Dim cmd As...
2
by: Shilpa | last post by:
Hi All, I want to pass XML and the data in the XML should be stored in the tables of the database. However, I do not want to use the OpenXML statement. Please let me know. Regards, Shilpa
2
by: Lauren Quantrell | last post by:
I can pass the XML below to a sproc from within a vb.net application but it doesn't work to the same sproc from an Access application. I've tried massaging the double quotes without success. Any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.