private SqlConnection conn;
private SqlDataAdapter da;
private SqlCommand cmd;
private SqlDataReader dr; public string AddAll(ArrayList a)
{
conn = new SqlConnection(ConfigurationSettings.AppSettings["dsn"]);
da = new SqlDataAdapter();
da.InsertCommand = new SqlCommand("Sp_Info_InsertAll",conn);
da.InsertCommand.CommandType = CommandType.StoredProcedure; da.InsertCommand.Parameters.Add("@BigSort",SqlDbType.VarChar,50).Value = a[0];
da.InsertCommand.Parameters.Add("@SmallSort",SqlDbType.VarChar,50).Value = a[1];
da.InsertCommand.Parameters.Add("@Title",SqlDbType.NVarChar,50).Value = a[2];
da.InsertCommand.Parameters.Add("@Source",SqlDbType.VarChar,50).Value = a[3];
da.InsertCommand.Parameters.Add("@Contant",SqlDbType.NVarChar,500).Value = a[4];
da.InsertCommand.Parameters.Add("@StrDate",SqlDbType.DateTime).Value = a[5];
da.InsertCommand.Parameters.Add("@Hit",SqlDbType.Int).Value = a[6]; conn.Open();
try
{
da.InsertCommand.ExecuteNonQuery();
}
catch(Exception e)
{
Console.Write(e.Message);
}
finally
{
conn.Dispose();
conn.Close();
} return "1";
}============================================================> private void btnAdd_Click(object sender, System.EventArgs e)
{
Db.Info MyInfo = new Info();
ArrayList a = new ArrayList();
a[0] = ddlBigSort.SelectedItem.Value;
a[1] = ddlSmallSort.SelectedItem.Value;
a[2] = txtTitle.Text.Trim();
a[3] = txtSource.Text.Trim();
a[4] = txtContant.Text.Trim();
a[5] = DateTime.Now;
a[6] = "0";
if(MyInfo.AddAll(a) == "1")
{
Response.Write("alert('添加成功!')");
}
else
{
Response.Write("alert('添加失败!')");
}
}==========================================================>异常详细信息: System.ArgumentOutOfRangeException: 索引超出范围。必须为非负值并小于集合大小。参数名: index源错误:
行 83: Db.Info MyInfo = new Info();
行 84: ArrayList a = new ArrayList();
行 85: a[1] = ddlBigSort.SelectedItem.Value;
行 86: a[2] = ddlSmallSort.SelectedItem.Value;
行 87: a[3] = txtTitle.Text.Trim();
源文件: c:\inetpub\wwwroot\webapplicationkflash\admin_addinfo.aspx.cs 行: 85
private SqlDataAdapter da;
private SqlCommand cmd;
private SqlDataReader dr; public string AddAll(ArrayList a)
{
conn = new SqlConnection(ConfigurationSettings.AppSettings["dsn"]);
da = new SqlDataAdapter();
da.InsertCommand = new SqlCommand("Sp_Info_InsertAll",conn);
da.InsertCommand.CommandType = CommandType.StoredProcedure; da.InsertCommand.Parameters.Add("@BigSort",SqlDbType.VarChar,50).Value = a[0];
da.InsertCommand.Parameters.Add("@SmallSort",SqlDbType.VarChar,50).Value = a[1];
da.InsertCommand.Parameters.Add("@Title",SqlDbType.NVarChar,50).Value = a[2];
da.InsertCommand.Parameters.Add("@Source",SqlDbType.VarChar,50).Value = a[3];
da.InsertCommand.Parameters.Add("@Contant",SqlDbType.NVarChar,500).Value = a[4];
da.InsertCommand.Parameters.Add("@StrDate",SqlDbType.DateTime).Value = a[5];
da.InsertCommand.Parameters.Add("@Hit",SqlDbType.Int).Value = a[6]; conn.Open();
try
{
da.InsertCommand.ExecuteNonQuery();
}
catch(Exception e)
{
Console.Write(e.Message);
}
finally
{
conn.Dispose();
conn.Close();
} return "1";
}============================================================> private void btnAdd_Click(object sender, System.EventArgs e)
{
Db.Info MyInfo = new Info();
ArrayList a = new ArrayList();
a[0] = ddlBigSort.SelectedItem.Value;
a[1] = ddlSmallSort.SelectedItem.Value;
a[2] = txtTitle.Text.Trim();
a[3] = txtSource.Text.Trim();
a[4] = txtContant.Text.Trim();
a[5] = DateTime.Now;
a[6] = "0";
if(MyInfo.AddAll(a) == "1")
{
Response.Write("alert('添加成功!')");
}
else
{
Response.Write("alert('添加失败!')");
}
}==========================================================>异常详细信息: System.ArgumentOutOfRangeException: 索引超出范围。必须为非负值并小于集合大小。参数名: index源错误:
行 83: Db.Info MyInfo = new Info();
行 84: ArrayList a = new ArrayList();
行 85: a[1] = ddlBigSort.SelectedItem.Value;
行 86: a[2] = ddlSmallSort.SelectedItem.Value;
行 87: a[3] = txtTitle.Text.Trim();
源文件: c:\inetpub\wwwroot\webapplicationkflash\admin_addinfo.aspx.cs 行: 85
解决方案 »
- sql where 条件为日期
- 关于向用户控件传值的问题
- 谁帮忙改下毕业设计的系统
- 绝对困惑DataGrid Button ItemCommand
- <cc1:dmenu id="Dmenu1" runat="server"></cc1:dmenu>是自定义控件还是什么?
- web页面上生成xml文件的问题
- 自己写一个select控件,怎么在LoadPostData中获得数据
- 如何从一个页面里清除另外一个页面里的gridview的数据?
- 如何自定义个性化的翻页按钮
- 请教各位大虾,我的系统为什么不支持aspx文件?急....
- 高手请进,救急救命!!!在线急等!!!
- 求用户选择条件生成sql的最佳解决方案
private void btnAdd_Click(object sender, System.EventArgs e)
{
Db.Info MyInfo = new Info();
ArrayList a = new ArrayList();
a.Add(ddlBigSort.SelectedItem.Value);
a.Add(ddlSmallSort.SelectedItem.Value);
a.Add(txtTitle.Text.Trim());
a.Add(txtSource.Text.Trim());
a.Add(txtContant.Text.Trim());
a.Add(DateTime.Now);
a.Add("0");
if(MyInfo.AddAll(a) == "1")
{
Response.Write("<script>alert('添加成功!')</script>");
}
else
{
Response.Write("<script>alert('添加失败!')</script>");
}
}