473,612 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Execute NonQuery();"
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.Sq lClient.SqlExce ption' occurred
in system.data.dll

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

string XMLDoc = "D:\\SEC\\Progr amming\\SEC DataBots\\SEC DataBot Test
Files\\Form 4\\From QS.xml";
StreamReader srXML = new StreamReader(XM LDoc);
string xmlDoc = srXML.ReadToEnd ();
SqlConnection sCon01 = new
SqlConnection(" server=AMD;Trus ted_Connection= yes;database=My Database");
SqlCommand sCmd01 = new
SqlCommand("_sp _Insert_Form_00 4_XML_template_ 07",sCon01);
sCmd01.CommandT ype = CommandType.Sto redProcedure;
sCmd01.Paramete rs.Add("@Form_0 04",SqlDbType.N Text).Value = xmlDoc;
sCmd01.Connecti on.Open();
sCmd01.ExecuteN onQuery();
sCmd01.Connecti on.Close();

Nov 17 '05 #1
1 2645
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.Execute NonQuery();"
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.Sq lClient.SqlExce ption' occurred
in system.data.dll

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

string XMLDoc = "D:\\SEC\\Progr amming\\SEC DataBots\\SEC DataBot Test
Files\\Form 4\\From QS.xml";
StreamReader srXML = new StreamReader(XM LDoc);
string xmlDoc = srXML.ReadToEnd ();
SqlConnection sCon01 = new
SqlConnection(" server=AMD;Trus ted_Connection= yes;database=My Database");
SqlCommand sCmd01 = new
SqlCommand("_sp _Insert_Form_00 4_XML_template_ 07",sCon01);
sCmd01.CommandT ype = CommandType.Sto redProcedure;
sCmd01.Paramete rs.Add("@Form_0 04",SqlDbType.N Text).Value = xmlDoc;
sCmd01.Connecti on.Open();
sCmd01.ExecuteN onQuery();
sCmd01.Connecti on.Close();

Nov 17 '05 #2

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

Similar topics

6
6730
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 dd/mm/yyyy date) AND in sql server 2000 sp i have:
4
1571
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 varchar value 'danwet w125 ' to a column of data type int. I have declared @Sellername as Varchar. Please can someone tell me what I'm
2
5266
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 clicks once they have selected the desired record. The button calls a report which uses a stored procedure as its record source. The SP has 2 input parameters, one of which is a datetime data type. In the input parameters data field of the...
1
13622
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 the sproc if a TextBox is empty. SqlCommand getLesNumbers = new SqlCommand(); getLesNumbers.CommandText="usp_getLesNumbers"; getLesNumbers.CommandType = CommandType.StoredProcedure; getLesNumbers.Connection = msoConn;
4
1823
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 and pass the info to the SQL box and it hiccups. I'll drop VS.NET into debug mode and step through the SPROCcreation and copy those values into Query Analyzer to get alittle more info. When I run the Query Analyer that data worksjust fine. What?! ...
0
2803
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 Excel.Workbook oBook = oExcel.Workbooks.OpenXML("C:\Test.xml") Now I want to apply the stylesheet Test.xsl defined in the XML file as: <?xml-stylesheet type='text/xsl' href='Test.xsl'?>
5
382
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 New SqlCommand("MenuItems", Myconn) cmd.CommandType = CommandType.StoredProcedure I would like to beable to get the SQL statement of "MenuItems" as a string and use it in another part of my code... How do I do this???
2
3698
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
1608
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 help is appreciated. lq XML text:
0
8105
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8246
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8415
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6076
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5532
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4045
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4109
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1413
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.