请建议在代码下面查询 [英] pls suggest query fo below code

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

问题描述





我正在尝试下面的代码来显示来自Call_reg表的Complaint_no以及来自数据库的new_tech表中的tech_name以及选择投诉号后。从下拉列表中,我想从另一个下拉列表中选择技术人员名称然后点击按钮点击插入Call_Allocation表



点击按钮可以有人建议我cmd命令查询插入相同的。




以粗体显示。



有人可以帮我。 ...



Hi,

I am trying below code to display Complaint_no from Call_reg table as well as tech_name from new_tech table from database and after selecting complaint no. from dropdownlist, i want to choose technician name from another dropdownlist and then on button click to be inserted in Call_Allocation table

On button click can somebody suggest me cmd command query for inserting the same.


mentioned in bold.

Can somebody help me please....

SqlCommand cmd;
SqlDataReader dr;
private string s;
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        ddlComplaint.Items.Insert(0, new ListItem("---Select---", "---Select---"));
        FillDropDownList();
        ddlAllow.Items.Insert(0, new ListItem("---Select---", "---Select---"));
        FillTechnicianDropDownList();
    }
}



// Fill Dropdownlist
public void FillDropDownList()
{
    s = WebConfigurationManager.ConnectionStrings["Callregister_connectionstring"].ConnectionString;
    con = new SqlConnection(s);
    con.Open();
    cmd = new SqlCommand("Select Complaint_no from Call_Reg where Status='Open'" , con);
    dr = cmd.ExecuteReader();
    while (dr.Read())
    {
        ddlComplaint.Items.Add(dr[0].ToString());
    }
    dr.Close();
    con.Close();
}

// Show data in GridView
protected void btnSearch_Click(object sender, EventArgs e)
{
    s = WebConfigurationManager.ConnectionStrings["Callregister_connectionstring"].ConnectionString;
    con = new SqlConnection(s);
    con.Open();
    cmd = new SqlCommand("Select * from Call_Reg where Complaint_no='" + ddlComplaint.SelectedItem.ToString() + "'", con);
    dr = cmd.ExecuteReader();
    GridView2.DataSource = dr;
    GridView2.DataBind();
    dr.Close();
    con.Close();
}

// Fill Technician
public void FillTechnicianDropDownList()
{
    s = WebConfigurationManager.ConnectionStrings["Callregister_connectionstring"].ConnectionString;
    con = new SqlConnection(s);
    con.Open();
    cmd = new SqlCommand("Select Fname from New_Tech", con);
    dr = cmd.ExecuteReader();
    while (dr.Read())
    {
        ddlAllow.Items.Add(dr[0].ToString());
    }
    dr.Close();
    con.Close();
}

protected void btnAllo_Click(object sender, EventArgs e)
{
    SqlConnection con = new SqlConnection("SERVER=KSHITIJA-PC; Initial Catalog=CRM;Integrated Security=True");
    //SqlCommand cmd = new SqlCommand("Update Call_reg set status='Assigned' Where Complaint_no= '" + ddlComplaint.SelectedItem.ToString() + "'", con);
    SqlCommand cmd = new SqlCommand(" insert into Call_Allocation values( "", con);
    try
    {
        con.Open();

        int i = cmd.ExecuteNonQuery();
        //int a = cmd1.ExecuteNonQuery();
        if (i  == 1)
        {
            ddlComplaint.SelectedItem.Text = "";
            EO.Web.MsgBoxButton mb = new EO.Web.MsgBoxButton("OK");
            MsgBox1.Show("Message: ", "Call Assigned to Technician", null, mb);
         }

    }
    catch (Exception ex)
    {
        EO.Web.MsgBoxButton mb = new EO.Web.MsgBoxButton("OK");
        MsgBox1.Show("Error: ", ex.Message, null, mb);

    }
    con.Close();
}

推荐答案

请不要一遍又一遍地问这个问题。你现在已经问过五次了。如果你只是一直在问同样的事情,那你就没有进展。如果你真的根本无法理解这一点,而且你出于某些疯狂的原因,你必须写一些你不知道如何写作的情况,你最好花一天时间阅读有关如何写作的内容。写这个SQL,而不是花一个星期一遍又一遍地问它直到有人决定花一个小时为你做你的工作,所以你可以盲目剪切并粘贴你不理解的答案
please stop asking this over and over again. You''ve asked it five times now. If you just keep asking the same thing, you''re not progressing. If you really can''t understand this at all, and you, for some insane reason, are in a situation where you HAVE to write something you have no clue how to write, you''d do better spending a day reading about how to write this SQL, than spending a week asking it over and over until someone decides to spend an hour doing your job for you, so you can blindly cut and paste an answer you do not understand


这篇关于请建议在代码下面查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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