sudharsan s

sudharsan s

  • NA
  • 204
  • 86.8k

invalid object name or table name in sql server 2008?

Aug 23 2012 3:46 AM


i created the temporary table name as tmpOutstanding.

create table #tmpOutstanding(int int NOT NULL IDENTITY , tmpbillno int NULL,tmpbilldat DATETIME,tmptotal int, tmpbal int )


use of temporary table


protected void cmdAddTest_Click(object sender, EventArgs e)
    {
        string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
        SqlConnection sqlConn = new SqlConnection(dbConn);
        string strSQL;
      
        sqlConn.Open();
     


        strSQL = "INSERT INTO [tmpOutstanding]([tmpbillno],[tmpbilldat],[tmpbal])VALUES('" + txtbillno1.Text + "','" + bill_date.Text + "','" + bill_amount.Text + "','" + out_amount.Text + "')";
        SqlCommand cmd1 = new SqlCommand(strSQL, sqlConn);
        cmd1.ExecuteNonQuery();



        string strSQL1 = "update FinalBill_Details set TotalCollected= TotalCollected+'" + out_amount.Text + "' where Bill_Number='" + txtbillno1.Text + "'";
        SqlCommand cmdItem = new SqlCommand(strSQL1, sqlConn);
        cmdItem.ExecuteNonQuery();

        SqlDataAdapter dadapter = new SqlDataAdapter("SELECT [tmpbillno],[tmpbilldat],[tmpbal] from [tmpOutstanding]", sqlConn);
        DataSet dset = new DataSet();
        dadapter.Fill(dset);
        gvReturn1.DataSource = dset;
        gvReturn1.DataBind();
        sqlConn.Close();
    }

cmd1.ExecuteNonQuery();

it shows the error invalid Object name '
tmpOutstanding'.

pls help me how to rectify this error or,, tell any method i want to follow this...



Answers (2)