怎么样存入数据库
和从数据库读出来?
<textarea id="Textarea1" name="content1" runat="server" style="width:600px;height:450px;visibility:hidden;"></textarea>
------解决方案--------------------
取textarea内容:
string stext2 = Textarea1.InnerHtml;
插入数据库:
string sql = "insert into info(content) values('" + stext2 + "')";
string connstr = ConfigurationManager.AppSettings["DbHelperConnectionString"].ToString();
SqlConnection connsql = new SqlConnection(connstr);
connsql.Open();
SqlCommand comm = new SqlCommand(sql, connsql);
int result = comm.ExecuteNonQuery();
connsql.Close();
Textarea1.InnerHtml = "";
//读取数据库内容
connsql.Open();
SqlCommand comm2 = new SqlCommand(sql, connsql);
SqlDataAdapter da = new SqlDataAdapter(comm2);
DataSet ds = new DataSet();
da.Fill(ds,"info");
string sneed = ds.Tables["info"].Rows[3]["content"].ToString();
Textarea1.InnerHtml = sneed;//读取内容 显示在textarea中
connsql.Close();