Re: SQL Server 2005 connection from VB.NET 2003



Here is the Function we use to connect our VS2003 VB.Net CF1.0 app to a
Varity of SqlExpress 2005 Databases. Can't imagine that it won't work with
it's big brother.

Public Function GetRemoteSqlDBConnectStr(ByVal strExtServerName As String,
ByVal strExtDbName As String) As String
' Purpose Returns the connect string for the remote Sql Database
Return "Server=" & strExtServerName & "; " _
& "Database=" & strExtDbName & "; Connect Timeout=10;" _
& "User ID=UserLogin; Password=PassWord;"
End Function

Been working for a couple years with named (not IP address) servers.

Typical Calling code"

Dim cn As New SqlConnection
cn.ConnectionString = GetRemoteSqlDBConnectStr("MyServer", "MyDatabase")
cn.Open()
' Do Stuff...
cn.Close
cn = Nothing

Ron W.

"Andy Baker" <abaker@xxxxxxxxxxxxxxxxxx> wrote in message
news:13hgvova0dh77ef@xxxxxxxxxxxxxxxxxxxxx
Our application is written in VB.NET 2003 and uses SQL Server 2000. We
have a customer who wants to upgrade SQL Server 2005, so I recently
installed the developer edition to check whether it worked with our
application. I changed the connection string on the PC application to
point to the new instance of SQL server, and to my surprise it worked and
connected to 2005 without any changes in code. However when I made the
same changes on the application that accesses SQL server from CE.NET
devices, it didn't and I get the error message 'SQL server does not exist
or access denied'. The code that I am using is:
Dim cn as SqlConnection
cn = New SqlConnection("Data Source=xxx.xxx.xxx.xxx; Initial
Catalog=Vanputer; User Id=****; Password=****")
cn.Open
where the IP address is the address of the PC where SQL Server 2005 is
installed, Vanputer is name of the database in SQL Server 2005, and User
Id and Password are set up as a user in SQL Server 2005. All I have done
has changed the IP address from the server where SQL Server 2000 is
installed to the one where 2005 is installed, backed up the database from
2000 and restored to 2005. My questions are:
1) Is it possible to connect to SQL Server 2005 from VB.NET 2003 and
compact framework 1.1 or do I have to use VB.NET 2005?
2) If it is possible, what else am I doing wrong? Do I have to install
anything else on the PC where 2005 is installed to allow access from CE
devices, or can I change the connection string / use ODBC instead of
SqlConnection?
Thanks in advance

Andy Baker






.



Relevant Pages

  • RE: Installing SP4 on SQL 2000
    ... SQL Server 2000 SP3a, x86 ... It seems like there is issue on your install. ... MCITP: Database Administrator ... "David G" wrote: ...
    (microsoft.public.sqlserver.setup)
  • RE: Installing SP4 on SQL 2000
    ... As you said this is a fresh install, so it should not be an issue. ... If you are installing are installing a fresh version of SQL Server 2000, ... MCITP: Database Administrator ... "David G" wrote: ...
    (microsoft.public.sqlserver.setup)
  • Re: Linking tables access - sql server 2005
    ... Another advantage of this method is that you don't need an ODBC setting on the local computer, ... Create a linked table to SQL Server without using a DSN ... Name of the table that you are linking to on the SQL Server database ... Function AttachDSNLessTable(stLocalTableName As String, stRemoteTableName As String, stServer As String, stDatabase As String, Optional stUsername As ...
    (microsoft.public.access.adp.sqlserver)
  • Re: Why do I need to restart the SQL service?
    ... > I use Wise Installation utility to install MSDE 2000A. ... what I do within the app is: ... Check to see if the database exists. ... > SQL Server does not exist or access denied. ...
    (microsoft.public.sqlserver.msde)
  • Re: SQL SERVER 2008 Express + SP1
    ... Again there are three service pack setups which are provided by Microsoft. ... Are u sure you are using correct version for your install? ... DB Dev SQL Server 2005 ... Script level upgrade for database 'master' failed because upgrade step ...
    (microsoft.public.sqlserver.setup)