Could a change of SQL ports break a data reader?

  • Thread starter Bill in Kansas City
  • Start date
B

Bill in Kansas City

Can a change of SQL port affect a SQLDataReader's ability to pull data?
The code that follows was working just fine yesterday, and the only
thing that's changed between then and now is the SQL port. The
connection string is updated with the port - aaa.bbb.ccc.ddd,eeee -
where eeee is the new port number. The connection comes in just fine,
state = 1 (though yesterday it was "Open", weird), and the query runs
without error in Query Analyzer.

Dim connectionString As String
connectionString = ConfigurationSettings.AppSettings("CxnStr")
' now we have a valid connection string
' Network Library=DBMSSOCN;Data Source=aaa.bbb.ccc.ddd,eeee;Initial
Catalog=myDB;User Id=myUser;Password=myPassword;application name=MyApp;

Dim sSQL As String = "exec
spVehicle_GetVehicleInformationByKeyfield " & Request("keyField") & ",
'" & Request("status") & "'"
' which translates to exec
spVehicle_GetVehicleInformationByKeyfield 12345, 'Used', which works

Dim conn As New SqlConnection(connectionString)
Dim cmd As New SqlCommand(sSQL, conn)
Dim objDr As SqlDataReader
conn.Open()
' state = 1

objDr =
cmd.ExecuteReader(system.data.commandbehavior.closeConnection)
' err.number = 0

if objDr.read() then
' this is where we went yesterday...
makedescription.text = objdr("makedescription")
modeldescription.text = objdr("modeldescription")
modelyear.text = objdr("modelyear")
stocknumber.text = objdr("stocknumber")
serialnumber.text = objdr("serialnumber")
listprice.text = objdr("listprice")
else
' this is where we go now
response.write("Unable to write vehicle information<BR>")
end if

The obvious answer is flip the port back to default and see if my code
starts working, but I'd like to avoid that if I can. To do that, I'd
have to disconnect all of our users and change the connection strings
in five different applications; not a good thing. I'd like to find an
answer like "Oh, all you have to do is specify the spoo of the fleem,
and you're all set..."

Thanks in advance for any insights.

- Bill in KC
 
S

Scott Allen

Hi Bill:

What happens now? Is there an exception? What's the error message? Are
you sure the query is still returning rows? Can you use SQL Profiler
to catch the statement that gets executed, paste it into query
analyzer and see if any rows come back?

Just some troubleshooting tips,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top