Invalid object name

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Reb

    #1

    Invalid object name

    Hi,

    I am using MSSQL server 2000. When i am running my code, i
    am getting the error System.Data.Sql Client.SqlExcep tion:
    Invalid object name 'Item'
    where Item is the name of a table.
    It seems like the code couldn't identify the table. any
    idea of what could be wrong?

    thanks

  • Juan Galdeano

    #2
    Re: Invalid object name

    Hi,
    Could you send the code?

    "Reb" <gbreb@yahoo.co m> wrote in message
    news:01a301c36d 2b$3d8e40a0$a00 1280a@phx.gbl.. .[color=blue]
    > Hi,
    >
    > I am using MSSQL server 2000. When i am running my code, i
    > am getting the error System.Data.Sql Client.SqlExcep tion:
    > Invalid object name 'Item'
    > where Item is the name of a table.
    > It seems like the code couldn't identify the table. any
    > idea of what could be wrong?
    >
    > thanks
    >[/color]


    Comment

    • Reb

      #3
      Re: Invalid object name

      Hi,

      I am actually getting to know about the code written by
      another person.

      There are many files involved with this.

      He has used typed dataset and has written all the sql
      statements in the InitializeCompo nent() in the start page.

      [color=blue]
      >-----Original Message-----
      >Hi,
      > Could you send the code?
      >
      >"Reb" <gbreb@yahoo.co m> wrote in message
      >news:01a301c36 d2b$3d8e40a0$a0 01280a@phx.gbl. ..[color=green]
      >> Hi,
      >>
      >> I am using MSSQL server 2000. When i am running my[/color][/color]
      code, i[color=blue][color=green]
      >> am getting the error System.Data.Sql Client.SqlExcep tion:
      >> Invalid object name 'Item'
      >> where Item is the name of a table.
      >> It seems like the code couldn't identify the table. any
      >> idea of what could be wrong?
      >>
      >> thanks
      >>[/color]
      >
      >
      >.
      >[/color]

      Comment

      • Juan Galdeano

        #4
        Re: Invalid object name

        Sorry about

        foreach(DataRow row in dsClientes.Tabl es["Cli_Client es"].Rows)
        {
        MessageBox.Show (row["fieldname"].ToString())
        }

        This must be:

        foreach(DataRow row in dsClientes.Tabl es["Item"].Rows)
        {
        MessageBox.Show (row["fieldname"].ToString())
        }

        Cut and Paste. ;-)
        "Juan Galdeano" <juang@ai-sl.com> wrote in message
        news:uEtVWrUbDH A.2548@TK2MSFTN GP09.phx.gbl...[color=blue]
        > I make this 2 methods that return a SQLConnection, the first one is for[/color]
        SQL[color=blue]
        > Server Security Scheme and the second is for Integrated Security Scheme.
        >
        > public static SqlConnection ConnectToSQL(st ring server, string database,
        > string user, string password)
        > {
        > string connectionstrin g = "server=" + server.Trim() + ";";
        > connectionstrin g += "uid=" + user + ";";
        > connectionstrin g += "pwd=" + password + ";";
        > connectionstrin g += "database=" + database.Trim() + ";";
        > SqlConnection connection = new SqlConnection(c onnectionstring );
        > connection.Open ();
        > return connection;
        > }
        >
        > public static SqlConnection ConnectToSQL(st ring server, string database)
        > {
        > SqlConnection nwindConn = new SqlConnection() ;
        > string connectionstrin g = "Data Source=" + server.Trim() + ";Integrate d
        > Security=SSPI;I nitial Catalog=" + database.Trim() + ";";
        > SqlConnection connection = new SqlConnection(c onnectionstring );
        > connection.Open ();
        > return connection;
        > }
        >
        > If this works fine then create the DataSet.
        >
        > DataSet ds = new DataSet("Test") ;
        > string sql = "SELECT * FROM Item";
        > (new SqlDataAdapter( sql, connection)).Fi ll(ds, "Item");
        >
        > After that, the DataSet ds should have the table and records. If you want
        > read the records, you could use:
        >
        > foreach(DataRow row in dsClientes.Tabl es["Cli_Client es"].Rows)
        > {
        > MessageBox.Show (row["fieldname"].ToString())
        > }
        >
        > Hope this help you.
        >
        > "Reb" <gbreb@yahoo.co m> wrote in message
        > news:085e01c36d 41$c73f1d90$a60 1280a@phx.gbl.. .[color=green]
        > > Hi,
        > >
        > > I am actually getting to know about the code written by
        > > another person.
        > >
        > > There are many files involved with this.
        > >
        > > He has used typed dataset and has written all the sql
        > > statements in the InitializeCompo nent() in the start page.
        > >
        > >[color=darkred]
        > > >-----Original Message-----
        > > >Hi,
        > > > Could you send the code?
        > > >
        > > >"Reb" <gbreb@yahoo.co m> wrote in message
        > > >news:01a301c36 d2b$3d8e40a0$a0 01280a@phx.gbl. ..
        > > >> Hi,
        > > >>
        > > >> I am using MSSQL server 2000. When i am running my[/color]
        > > code, i[color=darkred]
        > > >> am getting the error System.Data.Sql Client.SqlExcep tion:
        > > >> Invalid object name 'Item'
        > > >> where Item is the name of a table.
        > > >> It seems like the code couldn't identify the table. any
        > > >> idea of what could be wrong?
        > > >>
        > > >> thanks
        > > >>
        > > >
        > > >
        > > >.
        > > >[/color][/color]
        >
        >[/color]


        Comment

        Working...