locked
The specified table does not exist. RRS feed

  • Question

  • I have tried the following code to acess a database and select specific information. The database is MS SQL 2005 Compact and am coding in VB 2008 Express.

     

    Dim sqlcon As SqlCeConnection = New SqlCeConnection("Data Source=C:\Users\Me\Documents\Database.sdf")

    Dim ceda As SqlCeDataAdapter = New SqlCeDataAdapter("Select * From Locations Where ProductID = ' " & txtProductID.Text & " ' ", sqlcon)

    Dim ds As DataSet = New DataSet()

    ceda.Fill(ds, "Locations")

    dgvLocations.DataSource = ds.Tables("Locations").DefaultView

     

    When it gets to the line ceda.Fill(ds, "Locations") it gives me the following error:

     

    The specified table does not exist. [ Locations ]

     

     

    I have created the database and the tables. There is information in the tables as well.

    Wednesday, January 16, 2008 7:20 PM

Answers

  • Solved my problem.

    Dim sqlcon As SqlCeConnection = New SqlCeConnection("Data Source=C:\Users\Me\Documents\Database.sdf")

    was linking to wrong location. Code works fine now.

    Thursday, January 17, 2008 7:20 PM