Passing XML FileName to a Stored Proc

G

Guest

I have created a stored procedure to use OPENXML to update my SQL2000
database using an external XML file.

What I need help on is:
How to pass the XML file as a parameter to the stored procedure.
Do I call SqlParameter ? If yes, besides the file name, it wants to know
the dbType and size.

Can someone post the C# code to do that ?

Thanks in advance,
LW
 
G

Guest

Hope this helps:
string sprocName = "MySproc";
SqlConnection conn = new SqlConnection("");
SqlCommand cmd = new SqlCommand(sprocName, conn);

cmd.CommandType = CommandType.StoredProcedure;

SqlParameter[] parms = new SqlParameter[1];

parms[0] = new SqlParameter("FileName", SqlDbType.VarChar);
parms[0].Value = @"c:\temp\test.xml";

cmd.Parameters.Add(parms[0]);

SqlDataReader reader = cmd.ExecuteReader();
 
G

Guest

Sorry, forgot the connection string below:

SqlConnection conn = new
SqlConnection("SERVER=[SERVERNAME];DATABASE=[DBName];TRUSTED_CONNECTION=Yes");

RR said:
Hope this helps:
string sprocName = "MySproc";
SqlConnection conn = new SqlConnection("");
SqlCommand cmd = new SqlCommand(sprocName, conn);

cmd.CommandType = CommandType.StoredProcedure;

SqlParameter[] parms = new SqlParameter[1];

parms[0] = new SqlParameter("FileName", SqlDbType.VarChar);
parms[0].Value = @"c:\temp\test.xml";

cmd.Parameters.Add(parms[0]);

SqlDataReader reader = cmd.ExecuteReader();


LW said:
I have created a stored procedure to use OPENXML to update my SQL2000
database using an external XML file.

What I need help on is:
How to pass the XML file as a parameter to the stored procedure.
Do I call SqlParameter ? If yes, besides the file name, it wants to know
the dbType and size.

Can someone post the C# code to do that ?

Thanks in advance,
LW
 
G

Guest

Sorry, forgot the connection string below

SqlConnection conn = new
SqlConnection("SERVER=[SERVERNAME];DATABASE=[DBName];TRUSTED_CONNECTION=Yes");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top