Visual Basic .NET doesn't accept spaces in table and field names, so please
help to write such SQL statement.
SELECT no_, name, address, city, Bank Account No_
FROM Vendor INNER JOIN Vendor Bank Account
ON Vendor.no_ = Vendor Bank Account.Vendor no_
I have developed such code for selection only form table Vendor and it works
fine:
Dim myODBConnection As New OdbcConnection("DSN=NV")
Dim myODBCommand As OdbcCommand = New OdbcCommand()
txtResults.Clear()
myODBCommand.Connection = myODBConnection
myODBCommand.CommandText = "SELECT no_, name, address, city FROM vendor"
myODBCommand.CommandType = CommandType.Text
myODBConnection.Open()
Dim reader As OdbcDataReader
reader = myODBCommand.ExecuteReader
While reader.Read()
txtResults.Text = txtResults.Text & reader("No_") &
ControlChars.Tab & reader("Name") & ControlChars.Tab & ControlChars.Tab &
reader("Address") & ControlChars.CrLf & reader("City") & ControlChars.CrLf
End While
reader.Close()
myODBConnection.Close()
Volker
myODBCommand.CommandText = "SELECT [Bank Account No_] FROM [Vendor Bank
Account]"
But when I run report I recieve error message:
ERROR[42000][Simba][SimabEngine ODBC Driver]SELECT << ??? >>[Bank Account
No_] FROM [Vendor Bank Account]
What I am doing wrong?
"Daniel Rimmelzwaan" wrote:
> I believe that is what square brackets are for ( the [ and the ]
> characters). So if you need the value of the "Bank Account No_" field in the
> "Vendor Bank Account" table, you would do:
> SELECT [Bank Account No_] FROM [Vendor Bank Account] etc.
>
> "Sveta" <svetlana...@yahoo.com> wrote in message
> news:C4AB3FE0-FC4A-4CDD...@microsoft.com...
I don't know what kind of syntax you need with your application to
accomplish what you need to do, you will have to consult the documentation
for that. All I know is that you need to use square brackets for field and
table names when they have spaces in them. What you do seem to be missing is
the company name in the table name. Unless you modified some table
properties, the Vendor Bank Account table will be called "Company
Name$Vendor Bank Account" on SQL Server.
"Sveta" <svetlana...@yahoo.com> wrote in message
news:BA3E8F47-64CD-4EF2...@microsoft.com...
Visual Studio returns ??? When the syntax for your SQL query is incorrect.