Dealing with Spaces in a Database Name

  • Thread starter Thread starter Scott D
  • Start date Start date
S

Scott D

I have a third party application that has a SQL database I am trying
to work with this in my code but the database name has a space in it
so when I try the following connection string:

Dim connString As String = "server=10.0.0.1;uid=sa;pwd=;Initial
Catalog=Third Party"

I assume it is cutting the name off at "Third". I have no control
over the databases name otherwise I would just have named it correctly
with no spaces. I have tried using single quotes surrounding the name
but that did not seem to help. Any suggestions?
 
Maybe you can try


Dim connString As String = "server=10.0.0.1;uid=sa;pwd=;Initial
Catalog='Third Party'"

Bye.
 
Scott said:
I have a third party application that has a SQL database I am trying
to work with this in my code but the database name has a space in it
so when I try the following connection string:

Dim connString As String = "server=10.0.0.1;uid=sa;pwd=;Initial
Catalog=Third Party"

I assume it is cutting the name off at "Third". I have no control
over the databases name otherwise I would just have named it correctly
with no spaces. I have tried using single quotes surrounding the name
but that did not seem to help. Any suggestions?

Are you using the SqlConnection object, or some other data provider?

I have no problems with an Initial Catalog that contains spaces in the
name. That includes with or without putting the database name in single
quotes (it works either way).

If you're using VS.NET, use the Server Explorer to connect to the
database - you can use the connection string it generates (after
removing a few items that the ADO.NET SQL server provider does not
support).

If Server Explorer can't connect to the database, then you can
troubleshoot from there.

I'm using .NET Framework 1.1 and SQL Server 2000.
 
Back
Top