[英]Application_end event doesn't update the database when I close visual studio
So this is my Application_End
C# code used to update the database table with values from an array:所以这是我的
Application_End
C# 代码,用于使用数组中的值更新数据库表:
protected void Application_End(object sender, EventArgs e)
{
string conStr = Session["ConnectionString"].ToString();
string CMDDDStr = "SELECT * FROM Portfolio";
bool continueFlag = true; //use that somehow
if (continueFlag)
{
SqlDataAdapter daa = new SqlDataAdapter(CMDDDStr, conStr);
DataSet dss = new DataSet();
daa.Fill(dss);
for (int i = 0; i < dss.Tables[0].Rows.Count - 4; i++)
{
int[] services = (int[])Application["services"];
int index0 = services[i];
dss.Tables[0].Rows[i][i+4] = index0;
//// Create connected scenario connection
}
SqlCommandBuilder builder = new SqlCommandBuilder(daa);
daa.UpdateCommand = builder.GetUpdateCommand();
daa.Update(dss);
}
}
And this is the SQL of my database table:这是我的数据库表的 SQL:
CREATE TABLE [dbo].[Portfolio] (
[Description] NVARCHAR (MAX) NULL,
[ImageData] VARBINARY (MAX) NULL,
[delete] NVARCHAR (50) NULL,
[id] INT IDENTITY (1, 1) NOT NULL,
[service0] INT NULL,
[service1] INT NULL,
[service2] INT NULL,
[service3] INT NULL,
[service4] INT NULL,
PRIMARY KEY CLUSTERED ([id] ASC)
);
Problem is... This doesn't do anything.问题是......这没有任何作用。 It doesn't update the database - any ideas?
它不会更新数据库 - 有什么想法吗?
(the problem is with the code) (问题出在代码上)
string conaaaStr = Session["ConnectionString"].ToString();
string CMDDDStr = "SELECT * FROM Portfolio";
bool continuaeFlag = true; //use that somehow
if (continuaeFlag)
{
SqlDataAdapter daa = new SqlDataAdapter(CMDDDStr, conaaaStr);
DataSet dss = new DataSet();
daa.Fill(dss);
for (int i = 0; i < dss.Tables[0].Columns.Count - 4; i++)
{
int[] services = (int[])Application["services"];
int index0 = services[i];
dss.Tables[0].Rows[0][i + 4] = index0;
//// Create connected scenario connection
}
SqlCommandBuilder builder = new SqlCommandBuilder(daa);
builder.GetUpdateCommand();
daa.Update(dss);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.