[英]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
的表中。
#tbl_emp_answer
? #tbl_emp_answer
? #tmp_emp_details
instead? #tmp_emp_details
吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.