strange SQL error in SQL Server
I run this completely normal command:
Function GetVehicleStatus() As DataTable
Connection.Open()
Dim strSQL As String = "SELECT * FROM Auto"
Dim ReadOnlyTable As New DataTable
Adapter.SelectCommand = New SqlClient.SqlCommand(strSQL, Connection)
Adapter.Fill(ReadOnlyTable)
Connection.Close()
Return ReadOnlyTable
End Function
and get an error saying: "Invalid object name 'Auto'."
But trust me, Auto exists as a table in the database. I'm looking at it right now in VS. I even tried it with another table name and I got the same thing. It apparently connect correctly cuz I got lots of testing stuff before this and the connection.open runs fine. There's no reason I can see that it shouldn't run :( anyone see anything wrong with it or something?
Re: strange SQL error in SQL Server
Is Auto a reserved word? It might be. Try SELECT * FROM [Auto]
Re: strange SQL error in SQL Server
I tried another table name of Categories so if it is, it's not that :( For some reason VS seems to be locking the file which I don't remember it doing before. I have it open in the server explorer tab and when I tried to move or delete the database it wouldn't let me. That may have something do to with it. Also in class we had table ownership problems because the person who made the DB made it at their works (grrrr) so could that have something to do with it? I opened the project at home here and it just asked me if I wanted to make myself the table owner and I said yeah so I'm not sure what else would be wrong.
Update: well here's something interesting. There's no database at all in my bin/debug folder. Where's the copy if never, copy if newer, copy always option again? I even re-added the DB in server explorer and it's not in my solution explorer list. Couldda sworn it gets added in there and that's where U set it.