您能帮我看看那的代码出问题了吗?我试了半天,挨句在sql里试也不知道那出错了。。C#的连接代码
public string strcon = "Integrated Security=SSPI;Initial Catalog='db123';Data Source='Ghost-1383119';User ID='sa';Password='sa';Connect Timeout=0";
try
{
SqlConnection conn = new SqlConnection(strcon);
conn.Open();
strSQL = "select id,title,keyword from web where id<120 and id>98 order by id asc";
SqlDataAdapter da = new SqlDataAdapter(strSQL, conn);
da.SelectCommand.CommandTimeout = 60000; da.Fill(ds, "web");
conn.Close();
n = ds.Tables["web"].Rows.Count;
foreach (DataRow dr in ds.Tables["web"].Rows)
{
titleid = dr["id"].ToString();
xsort_id = dr["xsort_id"].ToString();
xdirect_unicode = dr["xdirect_unicode"].ToString(); if (titleid != null)
{
titleid = titleid.ToString();
}
long id = long.Parse(inputid);
string strNextSQL = "select top 1 id,title,time from web where keyword='" + keyword + "' and id>" + id + " order by id asc";
SqlConnection con = new SqlConnection(strcon);
con.Open();
SqlDataAdapter datar = new SqlDataAdapter(strPrevSQL, con);
DataSet ds = new DataSet();
datar.Fill(ds);
previd = ds.Tables[0].Rows[1]["id"].ToString();
prevtitle = ds.Tables[0].Rows[1]["title"].ToString();
prevdomainurl = ds.Tables[0].Rows[1]["url"].ToString();
prevcontent = ds.Tables[0].Rows[1]["content"].ToString(); ds = null;
con.Close(); SqlConnection mycon = new SqlConnection(strcon);
mycon.Open(); long id = long.Parse(inputid);
string strSQL = "select * from web where id=" + id;
SqlDataReader dr = null;
SqlCommand mycommand = new SqlCommand(strSQL, mycon);
dr = mycommand.ExecuteReader();
while (dr.Read())
{
titleid = dr["id"].ToString();
title = dr["title"].ToString();
}
dr.Close();
mycommand.CommandText = "update web set show_path=1 where id=" + long.Parse(inputid);
mycommand.ExecuteNonQuery();
mycon.Close(); }
ds = null; }
public string strcon = "Integrated Security=SSPI;Initial Catalog='db123';Data Source='Ghost-1383119';User ID='sa';Password='sa';Connect Timeout=0";
try
{
SqlConnection conn = new SqlConnection(strcon);
conn.Open();
strSQL = "select id,title,keyword from web where id<120 and id>98 order by id asc";
SqlDataAdapter da = new SqlDataAdapter(strSQL, conn);
da.SelectCommand.CommandTimeout = 60000; da.Fill(ds, "web");
conn.Close();
n = ds.Tables["web"].Rows.Count;
foreach (DataRow dr in ds.Tables["web"].Rows)
{
titleid = dr["id"].ToString();
xsort_id = dr["xsort_id"].ToString();
xdirect_unicode = dr["xdirect_unicode"].ToString(); if (titleid != null)
{
titleid = titleid.ToString();
}
long id = long.Parse(inputid);
string strNextSQL = "select top 1 id,title,time from web where keyword='" + keyword + "' and id>" + id + " order by id asc";
SqlConnection con = new SqlConnection(strcon);
con.Open();
SqlDataAdapter datar = new SqlDataAdapter(strPrevSQL, con);
DataSet ds = new DataSet();
datar.Fill(ds);
previd = ds.Tables[0].Rows[1]["id"].ToString();
prevtitle = ds.Tables[0].Rows[1]["title"].ToString();
prevdomainurl = ds.Tables[0].Rows[1]["url"].ToString();
prevcontent = ds.Tables[0].Rows[1]["content"].ToString(); ds = null;
con.Close(); SqlConnection mycon = new SqlConnection(strcon);
mycon.Open(); long id = long.Parse(inputid);
string strSQL = "select * from web where id=" + id;
SqlDataReader dr = null;
SqlCommand mycommand = new SqlCommand(strSQL, mycon);
dr = mycommand.ExecuteReader();
while (dr.Read())
{
titleid = dr["id"].ToString();
title = dr["title"].ToString();
}
dr.Close();
mycommand.CommandText = "update web set show_path=1 where id=" + long.Parse(inputid);
mycommand.ExecuteNonQuery();
mycon.Close(); }
ds = null; }
解决方案 »
- group top n, 可以同时用吗?
- 问个常 识问题,关于游标,看的邹健的文章想到的
- 复杂的交叉表,请大家帮忙。
- 急求一条SQL语句,有难度,希望能有好的方法!根据其中一个值,找出相应的值!谢谢!新的serial替换旧的, 如何找出某个serial所有替换过
- 请问在SQL server 2000的视图中是不是不允许带Case when then的语句?
- 数据导入的问题
- SQL Server 2000的效率问题(是否区分大小写)
- 请教一个难题:关于数据导出的中文问题,XML流中的中文被截断
- sql server在局域網內用電腦名稱可以連,但是用ip地址不能連(其它機都可以,就我的不行),提示sql 不存在或 拒絕訪問,請高手指點?
- 将 expression 转换为数据类型 datetime 时出现算术溢出错误。
- 安装2008版本后不能创建数据库
- SQLserver 2005应该调用什么存储过程才可以在新建用户时不让“强制实施密码策略”打上勾?
在ado支持max pool size,需要你在连接字符串里设定,不过这个也不是标本兼治的方法,还是要看你的程序