简体   繁体   English

我只需要临时表的插入查询

[英]I want just the insert query for a temp table

I am using C#.Net and Sql Server ( Windows Application ). 我正在使用C#.Net和Sql Server(Windows应用程序)。 I had created a temporary table. 我创建了一个临时表。 When a button is clicked, temporary table ( #tmp_emp_details ) is created. 单击按钮后,将创建临时表( #tmp_emp_details )。 I am having another button called "insert Values" and also 5 textboxes. 我有另一个名为“插入值”的按钮,还有5个文本框。 The values that are entered in the textbox are used and whenever com.ExecuteNonQuery(); 每当com.ExecuteNonQuery();时,都会使用在文本框中输入的值com.ExecuteNonQuery(); line comes, it throws an error message Invalid object name '#tbl_emp_answer'. 行来了,它会引发错误消息Invalid object name '#tbl_emp_answer'. . Below is the set of code.. Please give me a solution. 下面是一组代码。请给我一个解决方案。

Code for insert (in insert value button): 插入代码(在插入值按钮中):

private void btninsertvalues_Click(object sender, EventArgs e)  
        {
            username = txtusername.Text;
            examloginid = txtexamloginid.Text;
            question = txtquestion.Text;
            answer = txtanswer.Text;
            useranswer = txtanswer.Text;
            SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=tempdb;Integrated Security=True;");
            SqlCommand com = new SqlCommand("Insert into #tbl_emp_answer values('"+username+"','"+examloginid+"','"+question+"','"+answer+"','"+useranswer+"')", con);
            con.Open();
            com.ExecuteNonQuery();
            con.Close();
        }

You said you created the temporary table #tmp_emp_details but are trying to insert into a table of a different name, #tbl_emp_answer . 您说您创建了临时表#tmp_emp_details但是试图将其插入另一个名称为#tbl_emp_answer的表中。

  • Have you created the table #tbl_emp_answer ? 您是否创建了表#tbl_emp_answer
  • Should you be inserting into #tmp_emp_details instead? 您应该改为插入#tmp_emp_details吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我想要一个临时表的插入查询 - I want a insert query for a temp table 我想将数据插入表中 - I want to insert data into a table 存储过程返回多个临时表结果。 我想使用 C# 将它们复制到一个 CSV 文件中 - Stored procedure returns multiple temp table results. I want to copy them into one CSV file using C# 我已将表格字段和文本框值存储在两个不同的列表中 <string> 现在我想在插入查询中使用那些列表怎么做? - I have stored Table fields and Textbox values in two different list<string> now I want to use those lists in insert query how to do it? 如何在 c# 中打印? 我想打印一张表(查询) - how to print in c#? i want to print a table(query) 在ASP.NET C中的另一个查询中创建#temp表之后,从#Temp表中选择数据 - select data from #Temp table after #temp table create in another query in asp.net c# 我可以在Azure表中通过一个查询插入记录组 - Can I do insert group of record by one query in Azure Table 我想将数据插入数据库 - I want to insert the data to the database 我只想更改运行时的 URL? - I just want to change the URL on Runtime? 我想将列表框项目插入数据库,数据库值应为从其他表中获取的整数 - I want to insert the listbox items into the database where database value should be integer which is fetched from other table
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM