Passing XML FileName to a Stored Proc

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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();
 
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
 
Sorry, forgot the connection string below

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