use sqlxml access database

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.";
}
 
C

Chad Z. Hower aka Kudzu

=?Utf-8?B?Z29vZG1hbm5ld3o=?= said:
Could u please tell me why the following codes cannot run in webservice
while these codes can be run in a window form? Thanks.

It might be helpful if you defined what "cannot run" means.
 
G

goodmannewz

Thank you for your attention.

The following is the error messge from IE:
"HTTP 500 - Internal server error " after I invoked.
And I went through step by step debugging, the same error message was shown,
no further information.

Thanks
 
C

Chad Z. Hower aka Kudzu

=?Utf-8?B?Z29vZG1hbm5ld3o=?= said:
Thank you for your attention.

The following is the error messge from IE:
"HTTP 500 - Internal server error " after I invoked.
And I went through step by step debugging, the same error message was
shown, no further information.

Turn off friendly errors in IE, then try again to see what the real error is.
 
G

goodmannewz

Dear Chad,

Thank you very much for your reply.

I tried the same code on another machine. And I tried many way to specify a
path("../XMLSchema1.xsd" or "D:/Inetpub/wwwroot/WebService1/XMLSchema1.xsd"
or @"D:\Inetpub\wwwroot\WebService1\XMLSchema1.xsd") however all failed. The
error was the following:
Microsoft.Data.SqlXml.SqlXmlException: Schema: Cannot find the specified
schema file 'XMLSchema1.xsd'. --->
System.Runtime.InteropServices.COMException (0x800C0006): Schema: Cannot find
the specified schema file 'XMLSchema1.xsd'.
at
Microsoft.Data.SqlXml.Common.ISQLXMLCommandManagedInterface.ExecuteToOutputStream()
at Microsoft.Data.SqlXml.SqlXmlCommand.innerExecute(Stream strm)
--- End of inner exception stack trace ---
at Microsoft.Data.SqlXml.SqlXmlCommand.ExecuteStream()
at Microsoft.Data.SqlXml.SqlXmlCommand.ExecuteXmlReader()
at Microsoft.Data.SqlXml.SqlXmlAdapter.Fill(DataSet ds)
at WebService1.Service1.test() in
d:\inetpub\wwwroot\webservice1\service1.asmx.cs:line 76

Thanks again.

Ryan
 
C

Chad Z. Hower aka Kudzu

=?Utf-8?B?Z29vZG1hbm5ld3o=?= said:
specify a path("../XMLSchema1.xsd" or

NEVER use relative paths.
"D:/Inetpub/wwwroot/WebService1/XMLSchema1.xsd" or

This wont work, your slashes are wrong.
@"D:\Inetpub\wwwroot\WebService1\XMLSchema1.xsd") however all failed.
The error was the following:
Microsoft.Data.SqlXml.SqlXmlException: Schema: Cannot find the specified
schema file 'XMLSchema1.xsd'. --->

Is the file actually in this location?
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,817
Latest member
AdalbertoT

Latest Threads

Top