G
goodmannewz
Could u please tell me why the following codes cannot run in webservice while
these codes can be run in a window form? Thanks.
[WebMethod]
public string test()
{
DataRow tempRow;
SqlXmlAdapter ad;
MemoryStream ms=new MemoryStream();
SqlXmlCommand cmd=new SqlXmlCommand("Provider=SQLOLEDB;data
source=\"127.0.0.1\";initial catalog=Northwind;user id=\"test\";
password=\"test\"");
cmd.RootTag="ROOT";
cmd.CommandText="Emp";
cmd.CommandType=SqlXmlCommandType.XPath;
cmd.SchemaPath="..\\XMLSchema1.xsd";
DataSet ds = new DataSet();
ad=new SqlXmlAdapter(cmd);
ad.Fill(ds);
tempRow=ds.Tables["Emp"].Rows[0];
tempRow["FName"] = "Susan";
ad.Update(ds);
return "ok";
}
the codes in windows form:
private void button2_Click(object sender, System.EventArgs e)
{
DataRow row;
SqlXmlAdapter ad;
MemoryStream ms = new MemoryStream();
SqlXmlCommand cmd=new SqlXmlCommand("Provider=SQLOLEDB;data
source=\"127.0.0.1\";initial catalog=Northwind;user id=\"test\";
password=\"test\"");
cmd.RootTag = "ROOT";
cmd.CommandText = "Emp";
cmd.CommandType = SqlXmlCommandType.XPath;
cmd.SchemaPath = "..\\XMLSchema1.xsd";
DataSet ds = new DataSet();
ad = new SqlXmlAdapter(cmd);
ad.Fill(ds);
row = ds.Tables["Emp"].Rows[0];
row["FName"] = "Susan";
ad.Update(ds);
textBox1.Text="It is ok.";
}
these codes can be run in a window form? Thanks.
[WebMethod]
public string test()
{
DataRow tempRow;
SqlXmlAdapter ad;
MemoryStream ms=new MemoryStream();
SqlXmlCommand cmd=new SqlXmlCommand("Provider=SQLOLEDB;data
source=\"127.0.0.1\";initial catalog=Northwind;user id=\"test\";
password=\"test\"");
cmd.RootTag="ROOT";
cmd.CommandText="Emp";
cmd.CommandType=SqlXmlCommandType.XPath;
cmd.SchemaPath="..\\XMLSchema1.xsd";
DataSet ds = new DataSet();
ad=new SqlXmlAdapter(cmd);
ad.Fill(ds);
tempRow=ds.Tables["Emp"].Rows[0];
tempRow["FName"] = "Susan";
ad.Update(ds);
return "ok";
}
the codes in windows form:
private void button2_Click(object sender, System.EventArgs e)
{
DataRow row;
SqlXmlAdapter ad;
MemoryStream ms = new MemoryStream();
SqlXmlCommand cmd=new SqlXmlCommand("Provider=SQLOLEDB;data
source=\"127.0.0.1\";initial catalog=Northwind;user id=\"test\";
password=\"test\"");
cmd.RootTag = "ROOT";
cmd.CommandText = "Emp";
cmd.CommandType = SqlXmlCommandType.XPath;
cmd.SchemaPath = "..\\XMLSchema1.xsd";
DataSet ds = new DataSet();
ad = new SqlXmlAdapter(cmd);
ad.Fill(ds);
row = ds.Tables["Emp"].Rows[0];
row["FName"] = "Susan";
ad.Update(ds);
textBox1.Text="It is ok.";
}