Monday, March 26, 2012

VS 2003 + opening a connection to SQL SERVER 2000 database

Hey all
I am building a new computer.
I have Windows XP Pro with SP2 and all the updates.
I installed VS 2003.
Then copied a project from my old computer to the new one.
When I try and run the project .. it errors out saying it "sql server does
not exist or access denied"
The connection string is obviously the exact same as when it ran on the old
computer ... as all the files came from the old computer ... where the
project works just fine.
The MSSQL server is running on a seperate computer all together.
I can open query analyzer and access the database, no problem. On the new
machine.
I can even use Tools .. Connect to Database ... in VS 2003 IDE and that
works ...
Just in my vb.net code is it failing .. and again .. it work just fine on
the old development machine.
Any ideas '
Thanks
Jonwhat is your string connection?
"Jon Delano" <jd31068@.hotmail.com> escribi en el mensaje
news:aq-dnfWmw8UagODeRVn-rQ@.comcast.com...
> Hey all
> I am building a new computer.
> I have Windows XP Pro with SP2 and all the updates.
> I installed VS 2003.
> Then copied a project from my old computer to the new one.
> When I try and run the project .. it errors out saying it "sql server does
> not exist or access denied"
> The connection string is obviously the exact same as when it ran on the
> old computer ... as all the files came from the old computer ... where the
> project works just fine.
> The MSSQL server is running on a seperate computer all together.
> I can open query analyzer and access the database, no problem. On the new
> machine.
> I can even use Tools .. Connect to Database ... in VS 2003 IDE and that
> works ...
> Just in my vb.net code is it failing .. and again .. it work just fine on
> the old development machine.
>
> Any ideas '
> Thanks
> Jon
>
>
Is this a web app? What is does your connection string look like? Are you
connection to SQL using integrated security? Is it using trying to use your
local ASPNET account?
Greg
"Jon Delano" <jd31068@.hotmail.com> wrote in message
news:aq-dnfWmw8UagODeRVn-rQ@.comcast.com...
> Hey all
> I am building a new computer.
> I have Windows XP Pro with SP2 and all the updates.
> I installed VS 2003.
> Then copied a project from my old computer to the new one.
> When I try and run the project .. it errors out saying it "sql server does
> not exist or access denied"
> The connection string is obviously the exact same as when it ran on the
> old computer ... as all the files came from the old computer ... where the
> project works just fine.
> The MSSQL server is running on a seperate computer all together.
> I can open query analyzer and access the database, no problem. On the new
> machine.
> I can even use Tools .. Connect to Database ... in VS 2003 IDE and that
> works ...
> Just in my vb.net code is it failing .. and again .. it work just fine on
> the old development machine.
>
> Any ideas '
> Thanks
> Jon
>
>
Sorry for the bad grammar. :^) Let's try that again.
Is this a web app? What does your connection string look like? Are you
connecting to SQL using integrated security? Is it trying to use your local
ASPNET account?
"Greg Burns" <bluebunny@.newsgroups.nospam> wrote in message
news:OK%23Dbb96FHA.1864@.TK2MSFTNGP12.phx.gbl...
> Is this a web app? What is does your connection string look like? Are you
> connection to SQL using integrated security? Is it using trying to use
> your local ASPNET account?
Hello Thanks all for the quick replies ...
Here is the connection string as it sits in my web config file :
<add key="RepositoryConnectionString"
value=" server=server;uid=sa;pwd=password;databa
se=ShepherdRepository;Connect
Timeout=120" />
Here is the code that is running ...
If Not IsPostBack Then
Dim cmdCheckRepositoryAvailability As New SqlCommand
Dim rdrCheckRepositoryAvailability As SqlDataReader
Dim Conn As SqlConnection
Try
' check the flag for repository availability
Dim SQL As String
Conn = New
SqlConnection(ConfigurationSettings.AppSettings("RepositoryConnectionString"
))
Conn.Open()
SQL = "Select RepositoryAvailable from tblProperty"
cmdCheckRepositoryAvailability = New SqlCommand(SQL, Conn)
rdrCheckRepositoryAvailability =
cmdCheckRepositoryAvailability.ExecuteReader
If rdrCheckRepositoryAvailability.Read Then
If rdrCheckRepositoryAvailability("RepositoryAvailable")
= 0 Then
' its not available
txtUserName.Enabled = False
txtPassword.Enabled = False
btnLogin.Enabled = False
Label1.ForeColor = Color.Blue
Label1.Font.Bold = True
Label1.Font.Size = FontUnit.Medium
Label1.Text = "<center>The repository is unavailable
at this time.</center>"
End If
End If
Catch
txtUserName.Enabled = False
txtPassword.Enabled = False
btnLogin.Enabled = False
Label1.ForeColor = Color.DarkBlue
Label1.Font.Bold = True
Label1.Font.Size = FontUnit.Medium
Label1.Text = "<center>The repository is unavailable at this
time.</center>"
Finally
cmdCheckRepositoryAvailability.Dispose()
cmdCheckRepositoryAvailability = Nothing
If Not rdrCheckRepositoryAvailability Is Nothing Then
rdrCheckRepositoryAvailability.Close()
End If
rdrCheckRepositoryAvailability = Nothing
Conn.Close()
Conn = Nothing
End Try
This is a web application, I don't remember having to do anything special on
the old development machine to be able to connect to SQL Server.
As you can see I am using SQL Server Authentication (using sa is only in my
test network <grin> )
Thanks for any assistance, please let me know if there is anything else you
need.
Jon
jd31068@.hotmail.com
"Greg Burns" <bluebunny@.newsgroups.nospam> wrote in message
news:Oi%2311d96FHA.3044@.TK2MSFTNGP10.phx.gbl...
> Sorry for the bad grammar. :^) Let's try that again.
> Is this a web app? What does your connection string look like? Are you
> connecting to SQL using integrated security? Is it trying to use your
> local ASPNET account?
> "Greg Burns" <bluebunny@.newsgroups.nospam> wrote in message
> news:OK%23Dbb96FHA.1864@.TK2MSFTNGP12.phx.gbl...
>
I was not expecting to see sa being used. That definately eliminates a lot
of my theories. :^)
Only thing I have left to offer is perhaps XP SP2's firewall?
Greg
"Jon Delano" <jd31068@.hotmail.com> wrote in message
news:6v2dnalik4dp3eDenZ2dnUVZ_sSdnZ2d@.co
mcast.com...
> Hello Thanks all for the quick replies ...
> Here is the connection string as it sits in my web config file :
> <add key="RepositoryConnectionString"
> value=" server=server;uid=sa;pwd=password;databa
se=ShepherdRepository;Conne
ct
> Timeout=120" />
> Here is the code that is running ...
> If Not IsPostBack Then
> Dim cmdCheckRepositoryAvailability As New SqlCommand
> Dim rdrCheckRepositoryAvailability As SqlDataReader
> Dim Conn As SqlConnection
> Try
> ' check the flag for repository availability
> Dim SQL As String
> Conn = New
> SqlConnection(ConfigurationSettings.AppSettings("RepositoryConnectionStrin
g"))
> Conn.Open()
> SQL = "Select RepositoryAvailable from tblProperty"
> cmdCheckRepositoryAvailability = New SqlCommand(SQL, Conn)
> rdrCheckRepositoryAvailability =
> cmdCheckRepositoryAvailability.ExecuteReader
> If rdrCheckRepositoryAvailability.Read Then
> If
> rdrCheckRepositoryAvailability("RepositoryAvailable") = 0 Then
> ' its not available
> txtUserName.Enabled = False
> txtPassword.Enabled = False
> btnLogin.Enabled = False
> Label1.ForeColor = Color.Blue
> Label1.Font.Bold = True
> Label1.Font.Size = FontUnit.Medium
> Label1.Text = "<center>The repository is
> unavailable at this time.</center>"
> End If
> End If
> Catch
> txtUserName.Enabled = False
> txtPassword.Enabled = False
> btnLogin.Enabled = False
> Label1.ForeColor = Color.DarkBlue
> Label1.Font.Bold = True
> Label1.Font.Size = FontUnit.Medium
> Label1.Text = "<center>The repository is unavailable at
> this time.</center>"
> Finally
> cmdCheckRepositoryAvailability.Dispose()
> cmdCheckRepositoryAvailability = Nothing
> If Not rdrCheckRepositoryAvailability Is Nothing Then
> rdrCheckRepositoryAvailability.Close()
> End If
> rdrCheckRepositoryAvailability = Nothing
> Conn.Close()
> Conn = Nothing
> End Try
> This is a web application, I don't remember having to do anything special
> on the old development machine to be able to connect to SQL Server.
> As you can see I am using SQL Server Authentication (using sa is only in
> my test network <grin> )
> Thanks for any assistance, please let me know if there is anything else
> you need.
> Jon
> jd31068@.hotmail.com
>
> "Greg Burns" <bluebunny@.newsgroups.nospam> wrote in message
> news:Oi%2311d96FHA.3044@.TK2MSFTNGP10.phx.gbl...
>
Oh yeah ... the server that sql server 2000 is running on is Windows 2000
"Greg Burns" <bluebunny@.newsgroups.nospam> wrote in message
news:Oi%2311d96FHA.3044@.TK2MSFTNGP10.phx.gbl...
> Sorry for the bad grammar. :^) Let's try that again.
> Is this a web app? What does your connection string look like? Are you
> connecting to SQL using integrated security? Is it trying to use your
> local ASPNET account?
> "Greg Burns" <bluebunny@.newsgroups.nospam> wrote in message
> news:OK%23Dbb96FHA.1864@.TK2MSFTNGP12.phx.gbl...
>
I checked that ... I have it off .. as I am using NAT and am behind a
router.
The server I am connecting to is behind the router as well.
This is so strange ...
"Greg Burns" <bluebunny@.newsgroups.nospam> wrote in message
news:%238$qV0%236FHA.736@.TK2MSFTNGP09.phx.gbl...
>I was not expecting to see sa being used. That definately eliminates a lot
>of my theories. :^)
> Only thing I have left to offer is perhaps XP SP2's firewall?
> Greg
> "Jon Delano" <jd31068@.hotmail.com> wrote in message
> news:6v2dnalik4dp3eDenZ2dnUVZ_sSdnZ2d@.co
mcast.com...
>
You say you are getting "sql server does not exist or access denied", but I
don't see where you are recording the error in your catch statement. How
can you tell what the error is from the code you posted?
Try
...
Catch ex as exception
trace.warn(ex.tostring)
..
Finally
...
End Try
Change your catch to something like that. You could, of course, put a
breakpoint on the catch statement itself and take a look ex's value.
Greg
"Jon Delano" <jd31068@.hotmail.com> wrote in message
news:ZOWdnQvGsOV31eDeRVn-gg@.comcast.com...
> Oh yeah ... the server that sql server 2000 is running on is Windows 2000
> "Greg Burns" <bluebunny@.newsgroups.nospam> wrote in message
> news:Oi%2311d96FHA.3044@.TK2MSFTNGP10.phx.gbl...
>
In VS 2003 ... I had changed the catch to catch ex as exception ...
Then put a break point in that section ... when it stopped there ... I did a
quick watch on ex ...
"Greg Burns" <bluebunny@.newsgroups.nospam> wrote in message
news:uMp%23RE$6FHA.3592@.TK2MSFTNGP12.phx.gbl...
> You say you are getting "sql server does not exist or access denied", but
> I don't see where you are recording the error in your catch statement.
> How can you tell what the error is from the code you posted?
> Try
> ...
> Catch ex as exception
> trace.warn(ex.tostring)
> ...
> Finally
> ...
> End Try
> Change your catch to something like that. You could, of course, put a
> breakpoint on the catch statement itself and take a look ex's value.
> Greg
>
> "Jon Delano" <jd31068@.hotmail.com> wrote in message
> news:ZOWdnQvGsOV31eDeRVn-gg@.comcast.com...
>

0 comments:

Post a Comment