webservice的winform局域网软件在多人同时访问是出现查询sql2000数据表混乱
为啥只允许我给30分??
服务器:win2000,数据库SQL2000,平台VS2010,开发软件C#开发的winform的C/S局域网软件
在服务器建立了一个虚拟站点组建了一个webservice,单机调试没出过问题,局域网访问人少时也没出现问题,但是要是同时多人访问时,就会出现访问数据库混乱的情况,导致局域网所有使用该软件的全部瘫痪,一旦出现问题后无法解决,重启服务器有时也没效果,大概过1个小时后又恢复,请高手指点,问题在哪里,是IIS访问超限的原因还是代码有问题:
webservice代码如下:
namespace WebServer
{
/// <summary>
/// DBLib 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class DBLib : System.Web.Services.WebService
{
private static SqlConnection SqlCon { get; set; }
private static string _SqlConStr;
private static string SqlConStr
{
get
{
if (string.IsNullOrEmpty(_SqlConStr) )
_SqlConStr= ConfigurationManager.AppSettings["ConnectionString"];
return _SqlConStr;
}
}
private bool GetCon()
{
//if (SqlCon != null)
// return true;
try
{
SqlCon = new SqlConnection(SqlConStr);
SqlCon.Open();
return true;
}
catch (Exception ex)
{
SqlCon = null;
throw ex;
}
}
[WebMethod]
public DataSet GetData(string Sql, out string ExceptionStr)
{
try
{
ExceptionStr = null;
if (!GetCon())
return null;
DataSet ds = new DataSet();
DataTable dt = new DataTable();
ds.Tables.Add(dt);
try
{
SqlCommand Command = new SqlCommand(Sql, SqlCon);
SqlDataAdapter adapter = new SqlDataAdapter(Command);
adapter.Fill(dt);
//SqlCon.Close();
return ds;
}
catch (Exception ex)
{
ExceptionStr = ex.Message;
SqlCon.Close();
return null;
}
}
finally
{
SqlCon.Close();
}
}
[WebMethod]
public string ExecSql(string Sql, out string ExceptionStr)
{
try
{
ExceptionStr = null;
if (!GetCon())
return "连接" + "数据库失败";
try
{
SqlCommand Command = new SqlCommand(Sql, SqlCon);
Command.ExecuteNonQuery();
//SqlCon.Close();
return null;
}
catch (Exception ex)
{
ExceptionStr = ex.Message;
SqlCon.Close();
return "执行Sql语句失败,失败原因:" + ex.Message;
}
}
finally
{
SqlCon.Close();
}
}
}
winform部分代码:
public static DataTable GetData(string Sql)
{
DataTable dt = new DataTable();
string Exceptionstr = "";
var _dblib = dblib;
//跟踪到这一步是SQlL的查询字符串是正确的,但是不能再继续跟踪到服务器了
DataSet ds = _dblib.GetData(Sql, out Exceptionstr);
//但是返回的ds值就不是要查询的结果了,很是无助呀
if (ds != null)
{
return ds.Tables[0];
}
MessageBox.Show(Exceptionstr);
return null;
}
public static string ExecSql(string Sql)
{
string Exceptionstr = "";
string falg = "";
var _dblib = dblib;
falg = _dblib.ExecSql(Sql, out Exceptionstr);
if (falg != null)
{
MessageBox.Show(Exceptionstr);
return Exceptionstr;
}
else
{
return null;
}
}
跪求大侠们指点指点,谢谢
服务器:win2000,数据库SQL2000,平台VS2010,开发软件C#开发的winform的C/S局域网软件
在服务器建立了一个虚拟站点组建了一个webservice,单机调试没出过问题,局域网访问人少时也没出现问题,但是要是同时多人访问时,就会出现访问数据库混乱的情况,导致局域网所有使用该软件的全部瘫痪,一旦出现问题后无法解决,重启服务器有时也没效果,大概过1个小时后又恢复,请高手指点,问题在哪里,是IIS访问超限的原因还是代码有问题:
webservice代码如下:
namespace WebServer
{
/// <summary>
/// DBLib 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class DBLib : System.Web.Services.WebService
{
private static SqlConnection SqlCon { get; set; }
private static string _SqlConStr;
private static string SqlConStr
{
get
{
if (string.IsNullOrEmpty(_SqlConStr) )
_SqlConStr= ConfigurationManager.AppSettings["ConnectionString"];
return _SqlConStr;
}
}
private bool GetCon()
{
//if (SqlCon != null)
// return true;
try
{
SqlCon = new SqlConnection(SqlConStr);
SqlCon.Open();
return true;
}
catch (Exception ex)
{
SqlCon = null;
throw ex;
}
}
[WebMethod]
public DataSet GetData(string Sql, out string ExceptionStr)
{
try
{
ExceptionStr = null;
if (!GetCon())
return null;
DataSet ds = new DataSet();
DataTable dt = new DataTable();
ds.Tables.Add(dt);
try
{
SqlCommand Command = new SqlCommand(Sql, SqlCon);
SqlDataAdapter adapter = new SqlDataAdapter(Command);
adapter.Fill(dt);
//SqlCon.Close();
return ds;
}
catch (Exception ex)
{
ExceptionStr = ex.Message;
SqlCon.Close();
return null;
}
}
finally
{
SqlCon.Close();
}
}
[WebMethod]
public string ExecSql(string Sql, out string ExceptionStr)
{
try
{
ExceptionStr = null;
if (!GetCon())
return "连接" + "数据库失败";
try
{
SqlCommand Command = new SqlCommand(Sql, SqlCon);
Command.ExecuteNonQuery();
//SqlCon.Close();
return null;
}
catch (Exception ex)
{
ExceptionStr = ex.Message;
SqlCon.Close();
return "执行Sql语句失败,失败原因:" + ex.Message;
}
}
finally
{
SqlCon.Close();
}
}
}
winform部分代码:
public static DataTable GetData(string Sql)
{
DataTable dt = new DataTable();
string Exceptionstr = "";
var _dblib = dblib;
//跟踪到这一步是SQlL的查询字符串是正确的,但是不能再继续跟踪到服务器了
DataSet ds = _dblib.GetData(Sql, out Exceptionstr);
//但是返回的ds值就不是要查询的结果了,很是无助呀
if (ds != null)
{
return ds.Tables[0];
}
MessageBox.Show(Exceptionstr);
return null;
}
public static string ExecSql(string Sql)
{
string Exceptionstr = "";
string falg = "";
var _dblib = dblib;
falg = _dblib.ExecSql(Sql, out Exceptionstr);
if (falg != null)
{
MessageBox.Show(Exceptionstr);
return Exceptionstr;
}
else
{
return null;
}
}
跪求大侠们指点指点,谢谢
...全文
相关推荐
C#语言Winform的webService框架
**C#语言Winform的webService框架:HYAppFrame详解**HYAppFrame是一个全面的、基于Windows Forms(Winform)的应用程序框架,旨在为开发者提供一个高效
CSharp调用WebService实现手机号码归属地查询
WebService是一种基于网络的、分布式计算的技术,允许不同系统之间通过标准协议交换数据,如SOAP(简单对象访问协议)和HTTP。首先,我们需要理解WebService的工作原理。
C# Winform数据库应用设计(附开发案例
同时,还需要了解MDI(多文档界面)应用程序的开发步骤,这通常涉及到菜单的创建和子窗体的管理。了解***的组成和工作原理对于掌握数据访问是至关重要的。
基于VS2008实现的WinForm客户端管理
总结起来,这个项目是一个利用VS2008开发的WinForm客户端应用程序,集成了SQL数据库服务进行数据存储,通过MD5加密确保安全性,并利用Webservice实现客户端与服务器间的通信。
书籍查询服务(2.0)
**数据交换格式**: - 在Winform客户端与WebService之间,数据通常以XML或JSON格式进行交换。XML是一种结构化数据表示方式,易于机器解析,适合网络传输。


