1. if there is not much data, save your DataTable or DataSet in a Session variable, when you are ready to update the database, use a DataAdapter, call its Update method on the DataTable2. consider to reinstall IIS, don't forget to run
aspnet_regiis -i
aspnet_regiis -i
首先,新建一个虚拟目录(例如:myweb),该虚拟目录指向你的文件夹。
然后,找到一个.csproj.webinfo文件,用记事本打开,你会看到类似下面的代码:
<VisualStudioUNCWeb>
<Web URLPath = "http://192.168.1.4/webapp/webapp.csproj" />
</VisualStudioUNCWeb>
修改其中的192.168.1.4为你的IP,修改“webapp”为“myweb”(注:webapp.csproj不要修改),然后保存文件。
然后,双击.csproj文件,VS.NET打开项目.
when you update, DataTable dt;if (Session["MyTable"] == null)
{
dt = new DataTable();
dt.Columns.Add("col1", typeof(string));
dt.Columns.Add("col2", typeof(string)); Session["MyTable"] = dt;
}dt = (DataTable)Session["MyTable"];
//add new data hereDataRow dr = dt.NewRow();
dr["col1"] = ....;
dr["col2"] = ....;
dt.Rows.Add(dr);
...when you want to update,SqlDataAdapter da = new SqlDataAdapter("select * from yourtable where 1=2", connString);
SqlCommandBuilder cb = new SqlCommandBuilder(da); //assume yourtable has a primary key)
DataTable dt = (DataTable)Session["MyTable"];
da.Update(dt);
dt.AcceptChanges();