I am creating a simple software in vb net that open a connection to a sql server in which the name of the table that i need to retreive cointains an exclamation mark, the string for the sql statement i am using is the following.
Dim strSQL As String
strSQL = "select * from dbo.!Lotti"
dbo.!Lotti is the actual the name of what I am looking for.
the problem is that the exclamation mark is causing a lot of problems, since the program is telling me there is syntax error with "!".
What I have tried:
I have tried to connect to a different table with no ! in the name, everything went fine. So the problem is the ! itself.
Tried using
strSQL = "select * from [dbo.!Lotti]"
strSQL = "select * from ['dbo.!Lotti']"
strSQL = "select * from '[dbo.!Lotti]'"
UPDATE:
tried also
strSQL = "select * from [dbo.!Lotti]" and says invalid object name. We tried creating a copy of the database wite name dbo.Lotti and it works like this:
strSQL = "select * from dbo.Lotti"
but not like this:
strSQL = "select * from [dbo.Lotti] "
(says invalid object name)