none
error when using sqlcommand, invalid object + tablename RRS feed

  • Question

  • does any1 know why i get the error "invalid object" when i try to select and update?  i know the table is in there but it keep tell me that the table is not valid.

     

     

    here is my code.  any help is greatly appreaciated.  thanks

     

     

     

    ConnectionString = "Data Source=" + this.TxtServerName.Text + ";UID=" + this.TxtUserName.Text + ";PWD=" + this.TxtPassword.Text;

    if (DDListDatabase.Text.Length > 3)

    {

    ConnectionString += ";Initial Catalog=" + DDListDatabase.SelectedText;

    }

    try

    {

    Conn.Close();

    }

    catch { }

    Conn.ConnectionString = ConnectionString;

    SqlCommand TestCon = new SqlCommand(SQLCommand, Conn);

    try

    {

    Conn.Open();

    SqlDataReader SqlReader = TestCon.ExecuteReader(CommandBehavior.SingleResult);

    //TestCon.ExecuteReader(CommandBehavior.SingleResult);

    }

     

    Sunday, March 30, 2008 3:24 AM

Answers

All replies