Hi all,
Suppose in my SP there is one input paramter customerid,
another output parameter xmloutput result which is output parameter. My
requirement is I will pass customerid as input parameter, and stored procedure
will produce customer details based on that customerid which will be stored in
@xmloutput (output parameter). This part is done, getting the correct
result.
Now From C# I
want to call this store procedure that method will return dataset type. For
this I have followed the below steps but not getting exact result.
For example I got
this xmloutput after running the SP:
<doc><Customer CustomerID="5"><CustomerName>cust 1</CustomerName><address><street>add</street></address><contact><email>[email protected]</email><phone>020021452</phone><fax>020</fax></contact>
</Customer>
</doc>
From C# I want to get this output in tabular form. For this
I have written this code in DAL layer.
public DataSet GetCustomerDetails (string custnumber)
{
conn = "Connenction string goes here. "
try
{
conn.Open();
SqlCommand
command = new SqlCommand("GetXMLOutPut", conn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@Cust_Number", custnumber);
SqlParameter
xmloutput = command.Parameters.Add("@XML_Output",
SqlDbType.NVarChar,2000);
xmloutput.Direction = ParameterDirection.Output;
SqlDataAdapter
adapter = new SqlDataAdapter(command);
DataSet
ds = new DataSet();
adapter.Fill(ds, "Customer");
return
ds;
}
catch(Exception )
{
throw;
}
}
But when I am trying to call this method from presentation
layer and trying to displaying this in gridview I am not getting the result tabular
form. Its just displaying the xmloutput result in the form of xml file. How can
I display this info in tabular form. Any help pls???
What I should change in DAL layer method or somewhere????
Presentation layer
code:
DALClass obj
= new DALClass ();
string
custnumber = txtCustNo.Text;
DataSet
ds = obj.GetCustomerDetails(custnumber);
GridView1.DataSource = ds;
GridView1.DataMember = "Customer";
GridView1.DataBind();
While I am calling this method from presentation layer I am
getting the output in the following form which is not expected.
Column1
|
<doc><Customer CustomerID="5"><CustomerName>cust 1</CustomerName><address><street>add</street></address><contact>
<email>[email protected]</email><phone>020021452</phone><fax>020</fax></contact></Customer></doc>
|