主题:我想做一个分布式的管理系统,但连不上数据库(sql)
我想做一个分布式的管理系统,但连不上数据库(sqlserver),数据库已经做好了,并且已经向ASP.NET Web服务项目托拽connection组建和adapter组建,但无法运行。getData也不知干什么用的。以下是商业逻辑层的源代码(c#),并复程序说明。望指点
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;
namespace business
{
public Service1()
InitializeComponent();
}
private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
private System.Data.SqlClient.SqlConnection sqlConnection1;
//getData是干什么用的?怎么不用dataset?
[color=FF0000]private business.getData getData1;[/color]
//下列代码提供全部商品流水帐服务
[WebMethod]
public DataSet allLiuShuiZhang(string year1,string month1,string day1,string year2,string month2,string day2)
{
string date1=year1+"-"+month1+"-"+day1;
string date2=year2+"-"+month2+"-"+day2;
sqlDataAdapter1.SelectCommand.CommandText="SELECT * FROM shuye100 WHERE(日期>="+"'"+date1+"')"+"AND(日期<="+"'"+date2+"')"+" ORDER BY日期 ASC";
sqlDataAdapter1.Fill(getData1.shuye100);
return getData1;
}
//下列代码提供特定商品的流水帐服务
[WebMethod]
public DataSet singleLiuShuiZhang(string year1,string month1,string day1,string year2,string month2,string day2,string shangpinbianhao)
{
string date1=year1+"-"+month1+"-"+day1;
string date2=year2+"-"+month2+"-"+day2;
sqlDataAdapter1.SelectCommand.CommandText="SELECT * FROM shuye100 WHERE(日期>="+"'"+date1+"')"+"AND(日期<="+"'"+date2+"')"+" AND(商品编号="+"'"+shangpinbianhao+"+)"+"ORDER BY 日期 ASC";
sqlDataAdapter1.Fill(getData1.shuye100);
return getData1;
}
//下列代码提供从XX年XX月XX日到从XX年XX月XX日的所有商品的盈亏服务。
[WebMethod]
public string allInOut(string year1,string month1,string day1,string year2,string month2,string day2)
{
string sele="SELECT * FROM shuye100";
DateTime time1=new DateTime(Int32.Parse(year1),Int32.Parse(month1),Int32.Parse(day1));
double x=0;
double y=0;
sqlConnection1.Open();
sqlSelectCommand1=new SqlCommand(swlw,sqlConnection1);
SqlDataReader reader=sqlSelectCommand1.ExecuteReader();
while(reader.Read())
{
DateTime time=reader.GetDateTime(2);
if((time>=time1)&&(time<=time2))
{
double in1=reader.GetDouble(7);
double in2=reader.GetDouble(8);
x=x+in1*in2;
double out1=reader.GetDouble(5);
double out2=reader.GetDouble(6);
y=y+out1*out2;
}
}
reader.Close();
sqlConnection1.Close();
double end=x-y;
return end.ToString();
}
//下列代码提供特定时间段内特定商品的经营盈亏服务
[WebMethod]
public string singleInOut(string shangpinbianhao,string year1,string month1,string day1,string year2,string month2,string day2,string shangpinbianhao)
{
string sele="SELECT * FROM shuye100 WHERE "+"(商品编号="+"'"+shangpinbianhao+"'"+")";
DateTime time1=new DateTime(Int32.Parse(year1),Int32.Parse(month1),
Int32.Parse(day1));
DateTime time2=new DateTime(Int32.Parse(year2),Int32.Parse(month2),
Int32.Parse(day2));
double x=0;
double y=0;
sqlConnection1.Open();
sqlSelectCommand1=new SqlCommand(sele,sqlConnection1);
SqlDataReader reader=sqlSelectCommand1.ExecuteReader();
while(reader.Read())
{
DateTime time=reader.GetDateTime(2);
if((time>=time1)&&(time<=time2))
{
double in1=reader.GetDouble(7);
double in2=reader.GetDouble(8);
x=x+in1*in2;
double out1=reader.GetDouble(5);
double out2=reader.GetDouble(6);
y=y+out1*out2;
}
}reader.Close();
sqlConnection1.Close();
double end=x-y;
return end.ToString();
}
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;
namespace business
{
public Service1()
InitializeComponent();
}
private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
private System.Data.SqlClient.SqlConnection sqlConnection1;
//getData是干什么用的?怎么不用dataset?
[color=FF0000]private business.getData getData1;[/color]
//下列代码提供全部商品流水帐服务
[WebMethod]
public DataSet allLiuShuiZhang(string year1,string month1,string day1,string year2,string month2,string day2)
{
string date1=year1+"-"+month1+"-"+day1;
string date2=year2+"-"+month2+"-"+day2;
sqlDataAdapter1.SelectCommand.CommandText="SELECT * FROM shuye100 WHERE(日期>="+"'"+date1+"')"+"AND(日期<="+"'"+date2+"')"+" ORDER BY日期 ASC";
sqlDataAdapter1.Fill(getData1.shuye100);
return getData1;
}
//下列代码提供特定商品的流水帐服务
[WebMethod]
public DataSet singleLiuShuiZhang(string year1,string month1,string day1,string year2,string month2,string day2,string shangpinbianhao)
{
string date1=year1+"-"+month1+"-"+day1;
string date2=year2+"-"+month2+"-"+day2;
sqlDataAdapter1.SelectCommand.CommandText="SELECT * FROM shuye100 WHERE(日期>="+"'"+date1+"')"+"AND(日期<="+"'"+date2+"')"+" AND(商品编号="+"'"+shangpinbianhao+"+)"+"ORDER BY 日期 ASC";
sqlDataAdapter1.Fill(getData1.shuye100);
return getData1;
}
//下列代码提供从XX年XX月XX日到从XX年XX月XX日的所有商品的盈亏服务。
[WebMethod]
public string allInOut(string year1,string month1,string day1,string year2,string month2,string day2)
{
string sele="SELECT * FROM shuye100";
DateTime time1=new DateTime(Int32.Parse(year1),Int32.Parse(month1),Int32.Parse(day1));
double x=0;
double y=0;
sqlConnection1.Open();
sqlSelectCommand1=new SqlCommand(swlw,sqlConnection1);
SqlDataReader reader=sqlSelectCommand1.ExecuteReader();
while(reader.Read())
{
DateTime time=reader.GetDateTime(2);
if((time>=time1)&&(time<=time2))
{
double in1=reader.GetDouble(7);
double in2=reader.GetDouble(8);
x=x+in1*in2;
double out1=reader.GetDouble(5);
double out2=reader.GetDouble(6);
y=y+out1*out2;
}
}
reader.Close();
sqlConnection1.Close();
double end=x-y;
return end.ToString();
}
//下列代码提供特定时间段内特定商品的经营盈亏服务
[WebMethod]
public string singleInOut(string shangpinbianhao,string year1,string month1,string day1,string year2,string month2,string day2,string shangpinbianhao)
{
string sele="SELECT * FROM shuye100 WHERE "+"(商品编号="+"'"+shangpinbianhao+"'"+")";
DateTime time1=new DateTime(Int32.Parse(year1),Int32.Parse(month1),
Int32.Parse(day1));
DateTime time2=new DateTime(Int32.Parse(year2),Int32.Parse(month2),
Int32.Parse(day2));
double x=0;
double y=0;
sqlConnection1.Open();
sqlSelectCommand1=new SqlCommand(sele,sqlConnection1);
SqlDataReader reader=sqlSelectCommand1.ExecuteReader();
while(reader.Read())
{
DateTime time=reader.GetDateTime(2);
if((time>=time1)&&(time<=time2))
{
double in1=reader.GetDouble(7);
double in2=reader.GetDouble(8);
x=x+in1*in2;
double out1=reader.GetDouble(5);
double out2=reader.GetDouble(6);
y=y+out1*out2;
}
}reader.Close();
sqlConnection1.Close();
double end=x-y;
return end.ToString();
}