Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 825105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:12:06+00:00 2026-05-15T03:12:06+00:00

I am using C#.Net and Sql Server ( Windows Application ). I had created

  • 0

I am using C#.Net and Sql Server ( Windows Application ). I had created a temporary table. When a button is clicked, temporary table (#tmp_emp_answer) is created. I am having another button called “insert Values” and also 5 textboxes. The values that are entered in the textbox are used and whenever com.ExecuteNonQuery(); line comes, it throws an error message 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();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T03:12:07+00:00Added an answer on May 15, 2026 at 3:12 am

    Temp tables only exists in the context of and for the duration of the current connection, your connection only has an insert command you are not creating a temp table as such the temp table you are trying to insert into does not exist. Even if you were creating one as part of the same query that inserted the values, it would be dropped as soon as you closed the connection. If you want a table to persist between connections you need to create a normal table, insert the values, then drop it later when you have finished with it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Windows .net application using SQL Server 2005 Express as database, which
I have a .NET application which is connecting to the SQL Server using Windows
Using VB.Net, C#.Net and SQL Server. Windows Application I want to separate a code
I'm using VB.NET and Microsoft SQL Server 2005 to create an application. I was
I maintain a legacy ASP.Net Web application (using .Net 2.0 + SQL Server 2005
Example scenario in an ASP.NET application using SQL Server membership provider : 1) a
I have an application developed in ASP.NET MVC using Entity Framework / Sql Server
I've a ASP.Net application which utilizes SQL Server Stored Procedures and Web Services using
I am developing a Client-Server application using C# .NET Winforms with SQL Server 2008.
I created a database and some tables in C# using .NET SQL Server provider.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.