請大家一定幫幫我啊!

simonfoe 2004-04-30 09:36:04
如何把textbox中的內容,插入或更新到sql server 2000數據庫的text型字段中呢?
...全文
9 12 点赞 打赏 收藏 举报
写回复
12 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
singleflower 2004-04-30
你的语句这样写试试:
sqlstr="update E01 set E0111=@content where id=@iid";
  • 打赏
  • 举报
回复
simonfoe 2004-04-30
曾經對IMAGE型數據進行過操作,也不是很複雜,可是爲何TEXT型的數據在我這兒insert,update等都報錯.
  • 打赏
  • 举报
回复
simonfoe 2004-04-30
出錯:
Command text was not set for the command object.
  • 打赏
  • 举报
回复
vzxq 2004-04-30
没有分别啊。直接insert 吧
  • 打赏
  • 举报
回复
lxcc 2004-04-30
// Insert page code here
//
int MyInsertMethod(string au_id, string address, string city, string state, string zip, bool contract) {
string connectionString = "server=\'(local)\'; user id=\'sa\'; password=\'\'; database=\'pubs\'";
System.Data.IDbConnection dbConnection = new System.Data.SqlClient.SqlConnection(connectionString);

string queryString = "INSERT INTO [authors] ([au_id], [au_lname], [au_fname], [address], [city], [state" +
"], [zip], [contract]) VALUES (@au_id, , , @address, @city, @state, @zip, @contra" +
"ct)";
System.Data.IDbCommand dbCommand = new System.Data.SqlClient.SqlCommand();
dbCommand.CommandText = queryString;
dbCommand.Connection = dbConnection;

System.Data.IDataParameter dbParam_au_id = new System.Data.SqlClient.SqlParameter();
dbParam_au_id.ParameterName = "@au_id";
dbParam_au_id.Value = au_id;
dbParam_au_id.DbType = System.Data.DbType.String;
dbCommand.Parameters.Add(dbParam_au_id);
System.Data.IDataParameter dbParam_address = new System.Data.SqlClient.SqlParameter();
dbParam_address.ParameterName = "@address";
dbParam_address.Value = address;
dbParam_address.DbType = System.Data.DbType.String;
dbCommand.Parameters.Add(dbParam_address);
System.Data.IDataParameter dbParam_city = new System.Data.SqlClient.SqlParameter();
dbParam_city.ParameterName = "@city";
dbParam_city.Value = city;
dbParam_city.DbType = System.Data.DbType.String;
dbCommand.Parameters.Add(dbParam_city);
System.Data.IDataParameter dbParam_state = new System.Data.SqlClient.SqlParameter();
dbParam_state.ParameterName = "@state";
dbParam_state.Value = state;
dbParam_state.DbType = System.Data.DbType.StringFixedLength;
dbCommand.Parameters.Add(dbParam_state);
System.Data.IDataParameter dbParam_zip = new System.Data.SqlClient.SqlParameter();
dbParam_zip.ParameterName = "@zip";
dbParam_zip.Value = zip;
dbParam_zip.DbType = System.Data.DbType.StringFixedLength;
dbCommand.Parameters.Add(dbParam_zip);
System.Data.IDataParameter dbParam_contract = new System.Data.SqlClient.SqlParameter();
dbParam_contract.ParameterName = "@contract";
dbParam_contract.Value = contract;
dbParam_contract.DbType = System.Data.DbType.Boolean;
dbCommand.Parameters.Add(dbParam_contract);

int rowsAffected = 0;
dbConnection.Open();
try {
rowsAffected = dbCommand.ExecuteNonQuery();
}
finally {
dbConnection.Close();
}

return rowsAffected;
}
  • 打赏
  • 举报
回复
simonfoe 2004-04-30
This is Code
//FileOp.aspx.cs
using FilesO
protected System.Web.UI.WebControls.TextBox txt;
FileOperate obj=new FileOperate()
obj.Cont=txt.Text;
obj.Oper();

//FileOperate.cs
namespace FilesO
private string ctn;
public string Cont
{
get
{
return ctn;
}
set
{
ctn=value;
}
}
public void Oper()
{
SqlTransaction objTrans =objCn.BeginTransaction();
objCmd.Transaction= objTrans;
string iid=this.GetMaxId("file","fileid",id);
sqlstr="update E01 set E0111=? where id='"+iid;
objCmd.CommandText=sqlstr;
objCmd.Parameters.Add(new SqlParameter("@content",SqlDbType.Text));
objCmd.Parameters["@content"].Value=ctn;
objCmd.ExecuteNonQuery();
objTrans.Commit();
}
  • 打赏
  • 举报
回复
liuyu202 2004-04-30
用sqlcommand或OledbCommand插入或更新!
  • 打赏
  • 举报
回复
aspdinet 2004-04-30
不太明白意思,如果只是单纯的更新或新增直接写就OK了,呵~~~,我想不是这么简单的问题你会拿出来用。说祥细点啦
  • 打赏
  • 举报
回复
jierry007 2004-04-30
插入语句就可以了啊-->tetxbox.text
  • 打赏
  • 举报
回复
riconyi 2004-04-30
:)
  • 打赏
  • 举报
回复
hfwang009 2004-04-30
直接写就可以阿
能不能说得详细点
  • 打赏
  • 举报
回复
thinkingforever 2004-04-30
就是插入或更新语句,你自己是怎样想的
  • 打赏
  • 举报
回复
相关推荐
发帖
.NET社区
加入

5.9w+

社区成员

.NET技术交流专区
申请成为版主
帖子事件
创建了帖子
2004-04-30 09:36
社区公告
暂无公告