上万分的老帐号没了,新注册个帐号来问个奇怪的问题
没分见谅,但是问题太奇怪,想得到各位支持,多谢了.
一个客户有SQL SERVER 2000数据库,已经打了SP4,有一表,表内一字段为DATETIME,我在客户那用SQL SERVER 的企业管理器查询数据都没问题,比如一条记录那个日期字段显示为"2012-11-16 23:59:59".
现在我写了一个WEBSERVICE,具体代码如下:
public SqlConnection connect_db(string con_str)
{
SqlConnection db_con = new SqlConnection();
db_con.ConnectionString = con_str;
try
{
db_con.Open();
}
catch
{
db_con = null;
}
return db_con;
}
public System.Data.DataSet get_data(SqlConnection con_db, string sql_str, string table_name)
{
System.Data.DataSet ds = new System.Data.DataSet();
try
{
SqlDataAdapter mydata = new SqlDataAdapter(sql_str, con_db);
mydata.Fill(ds, table_name);
}
catch
{
ds = null;
}
return ds;
}
[WebMethod]
public System.Data.DataSet get_pos(string pj)
{
System.Data.DataSet ds = new System.Data.DataSet();
SqlConnection db_con = new SqlConnection();
db_con.ConnectionString="server="+dbsource+";database="+dbname+";integrated security=SSPI";
try
{
ds.Clear();
string sql_string = "select * from TABLE1 where id='XX'";//查出那条记录
db_con.Open();
ds = db.get_data(db_con, sql_string, "pos_ls");
}
finally
{
db_con.Close();
}
return ds;
}
然后在浏览器中调用该WEBSERVICE得到如下结果:
<?xml version="1.0" encoding="utf-8" ?>
- <DataSet xmlns="http://tempuri.org/">
- <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
- <xs:complexType>
- <xs:choice minOccurs="0" maxOccurs="unbounded">
- <xs:element name="pos_ls">
- <xs:complexType>
- <xs:sequence>
<xs:element name="id" type="xs:string" minOccurs="0" />
<xs:element name="yx_date" type="xs:dateTime" minOccurs="0" />
<xs:element name="price" type="xs:decimal" minOccurs="0" />
<xs:element name="jzbz" type="xs:int" minOccurs="0" />
<xs:element name="ticket_type_id" type="xs:int" minOccurs="0" />
<xs:element name="typestr" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
- <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
- <NewDataSet xmlns="">
- <pos_ls diffgr:id="pos_ls1" msdata:rowOrder="0">
<ticket_id>XX</ticket_id>
<yx_date>2012-5-16T23:59:59+08:00</yx_date> //大家注意这里,数据库表中该字段内容是2012-11-15 23:59:59,但是查出来却是2012-5-16
<price>20.0000</price>
<jzbz>0</jzbz>
<ticket_type_id>1</ticket_type_id>
<typestr>AA</typestr>
</pos_ls>
</NewDataSet>
</diffgr:diffgram>
</DataSet>
大家帮我看看,到底哪有问题了
[解决办法]
该回复于2012-06-02 13:57:19被版主删除