查询表格 [英] Query regarding table

查看:42
本文介绍了查询表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

protected void Button_Click(object sender, EventArgs e)
{
    string a = Request.Params.ToString();
    string[] b = Request.Params["days"].Split(',');
    string[] c = Request.Params["subject"].Split(',');
    string[] d = Request.Params["teacher"].Split(',');
    string[] f = Request.Params["StartTime"].Split(',');
    string[] g = Request.Params["EndTime"].Split(',');

    string output = "<html><body>College: Anuradha College<br />Course: " + drpCourses.SelectedItem.Text +
     "<br />Stream: " + drpBranch.SelectedItem.Text + "<br /> Section: " + drpSection.SelectedItem.Text +
     "<br/>Day\t    Subject\t     Teacher\t      Start Time\t      End Time<br />DYNAMIC</body></html>";;
    String dynamic = "";
    for (int i = 0; i < b.Length; i++)
    {
        dynamic = dynamic + " " + b[i] + "  \t" + c[i] + " \t" + d[i] + " \t" + f[i] + " \t" + g[i] + "<br />";
    }

    int h = b.Length;
    for (int i = 0; i< h; i++)
    {
        string s = "insert into V2_TimeTable(CollageId,CourseId,StreamId,SectionId,Day,SubjectId,TeacherId,StartTime,EndTime) Values("+ 1 +", "+ drpCourses.SelectedValue + "," + drpBranch.SelectedValue + "," + drpSection.SelectedValue + "," + b[i].ToString() + "," + c[i].ToString() + "," + d[i].ToString() + " , '" + f[i].ToString() + "' , '" + g[i].ToString()  + "' )";
        obj.update(s);
        Response.Write("<script LANGUAGE='JavaScript' >alert('SUCCESSFULLY INSERTED')</script>");
}





我试图动态添加多行并尝试将所有行数据存储在数据库中。我有在按钮单击时使用此代码。但是它显示错误,并且错误是对象实例为空(不一样,但它像是dis)在第一行是字符串一行....任何人都可以帮助我解决dis?



I am trying to add multiple row dynamically and trying to store all the row data in the database.I have used this Code in button click.But it is showing an error and the error is"object instance is null(not the same but its like dis) on the first line that is string a line....Can anyone help me in solving dis?

推荐答案

如果在此行发生
string a = Request.Params.ToString();

然后请求尚未初始化或不包含 Params



所以你的问题不在这个代码中,而是你的表格中的其他地方,在你点击按钮之前。



同时 Params 返回一个集合,所以 Request.Params.ToString(); 将只返回描述性文本,而不是任何值。



进一步参考示例... at msdn [ ^ ]

then either Request has not been initialised or does not contain Params

So your problem is not in this code, but elsewhere in your form, before you get to the point where you click the button.

Also Params returns a collection so Request.Params.ToString(); will just return descriptive text, not any value.

Further reference with an example...at msdn[^]


这篇关于查询表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆