在C #中如何执行多条sql语句
SqlConnection thisConnection = new SqlConnection(
@"Data Source=61.129.*.*;Initial Catalog=authru_cn;User Id=****;Password=******");
thisConnection.Open();
SqlCommand thisCommand= thisConnection.CreateCommand();
thisCommand.CommandText=""
我要执行的sql语句是
declare @uid int
declare @date datetime
set @date=DateAdd(mm,1,GetDate())
update authru_cn.dbo.Login set Connect=128,ExpiredTime=4800,LastInDate=@date where UID=10003001
c#的代码不知道该怎么写了~~~
麻烦大家帮帮~~~
问题点数:20、回复次数:8Top
1 楼simonzone(马叉虫)回复于 2004-12-04 12:54:18 得分 0
为何不写到存储过程里呢.Top
2 楼ysjhuuuu(风蓝)回复于 2004-12-04 12:57:13 得分 0
sql不熟悉~~~ 怕写存储过程了有别的问题~ 而且数据库比较重要~~Top
3 楼ysjhuuuu(风蓝)回复于 2004-12-04 13:03:02 得分 0
已经解决~
switch (comboBox2.Text)
{
case "80小时":thisCommand.CommandText="declare @uid int\ndeclare @date datetime\nset @date=DateAdd(mm,1,GetDate())\nupdate authru_cn.dbo.Login set Connect=128,ExpiredTime=4800,LastInDate=@date where UID="+Convert.ToInt32(textBox5.Text);
thisCommand.ExecuteNonQuery();
break;
Top
4 楼FlashElf(銘龘鶽)回复于 2004-12-04 18:56:42 得分 10
thisCommand.CommandText=@"declare @uid int
declare @date datetime
set @date=DateAdd(mm,1,GetDate())
update authru_cn.dbo.Login set Connect=128,ExpiredTime=4800,LastInDate=@date where UID=10003001;"
Top
5 楼swzlxm(守望者)回复于 2004-12-04 19:29:44 得分 5
直接空格空開不就得了,賦給它就可以了,Top
6 楼Happy2046(雪山飞狐)回复于 2004-12-04 20:11:14 得分 0
^_^Top
7 楼peng1014()回复于 2004-12-04 20:18:29 得分 0
还是用存储过程来得好Top
8 楼xjaifly(tiantian)回复于 2004-12-04 22:12:50 得分 5
用调用存储过程那样写,CommandType.StoredProcedure ;
把你用到的函数在oracle中建好!
在程序中调用名字就可以!
代码就不具体给了Top




