Showing posts with label existing. Show all posts
Showing posts with label existing. Show all posts

Tuesday, March 27, 2012

cant get data from sql

I'm adding a few simple pages to our existing website to be able to keep all of our vendor information. Most of the rest of the website is using a Microsoft Access database. This new portion though is being built using a SQL database. For some reason though I seem to be unable to pull any information from the sql database, I've added the sql connection string into the main web.config file, as well as importing all the needed namespaces. I don't get any errors when I view the pages, but also get nothing from the database. What might I need to look at for this issue, I'm confused about why I can't get any data from the db. Any help is greatly appreciated.

Hey,

What might the code you are using look like?

|||

here's my connection string in the web.config -- minus user id and password, and an example of how I'm trying to pull data

<

addname="SQLConnString"connectionString="Data Source=UELIIS;Initial Catalog=ITtech;Persist Security Info=True;User ID=*****;Password=*****"providerName="System.Data.SqlClient"/>

PrivateSub GetMaxVendorNum()

Dim NextVendorNumAsString

strSql =

"SELECT MAX(VendorNum) + 1 AS Expr1FROM Vendor"

dr = GetDataReader(strSql, strConn)

If dr.Read()Then

NextVendorNum = dr(

"Expr1").ToString

lblVendorNum.Text = NextVendorNum.ToString

EndIfEndSubPublicSharedFunction GetDataReader( _ByVal SQLStatementAsString, _ByVal ConnectionStringAsString)As SqlDataReaderDim drAs SqlDataReaderDim cmdAsNew SqlCommandWith cmd

.Connection = _

New SqlConnection(ConnectionString)

.Connection.Open()

.CommandText = SQLStatement

dr = .ExecuteReader(CommandBehavior.CloseConnection)

EndWithReturn drEndFunction

Thanks for your help

|||

Hey,

I tried your query, and that worked for me. The only thing I can think of is the fact that you are returning the data reader and something is happening in between. Is the problem that you are getting no entries or that you are getting an error thrown.

|||I'm just not getting any entries, just blank fields|||The really crazy thing is that on my first page I'm using a sqldatasource to populate a gridview and it pulls and displays the information with no problem. Its using the same connection string as my other pages.|||

well i've narrowed it down to the fact that my page_load event isn't firing for some reason, I even tried to put a script tag in the .aspx page and place it there instead of a code behind page but still nothing, can't even put text into the error label. Here's some of my code snippets that may help troubleshoot problem.

<%

@.PageLanguage="VB"AutoEventWireup="false"CodeFile="VendorEdit.aspx.vb"Inherits="VendorEdit" %>

Partial

Class VendorEdit

Inherits

System.Web.UI.Page

.... CODE.....

end class

Ask if you need to see any code or need more information. Thanks for your help.

|||

Hi,

Thanks for your code.

I tried it on my machine and it works fine. The only problem seems that I cannot see any code that your DataReader is binding to. Did you set it as the datasource of a GridView?

If so, please also call GridView.DataBind() after it has been set as the DataSource.

HTH.

|||

could you post your page_load event code make sure its something like following

Protected

Sub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.LoadEndSub

handles me.load is must.

thanks,

satish.

Sunday, February 19, 2012

Can't connect to SQL server after hibernating

Hi,
I currently have a development SQL server running locally on my laptop.
After my laptop comes out of hibernation, existing connections to the server
,
such as from Query Analyzer, work fine, but I can not make new connections t
o
the server. I've tried restarting the server through the SQL Server Service
Manager, but it doesn't solve the problem. The only way to be able to
re-establish a connection is to reboot; which makes developing on the laptop
difficult.
Here is the result of "select @.@.Version":
Microsoft SQL Server 2000 - 8.00.944 (Intel X86) May 19 2004 18:32:44
Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on Windows
NT 5.1 (Build 2600: Service Pack 2)What exact errors do you get when you can't connect?
Did you check the event logs for errors?
-Sue
On Wed, 12 Oct 2005 11:21:09 -0700, Andy Rondeau <Andy
Rondeau@.discussions.microsoft.com> wrote:

>Hi,
>I currently have a development SQL server running locally on my laptop.
>After my laptop comes out of hibernation, existing connections to the serve
r,
>such as from Query Analyzer, work fine, but I can not make new connections
to
>the server. I've tried restarting the server through the SQL Server Servic
e
>Manager, but it doesn't solve the problem. The only way to be able to
>re-establish a connection is to reboot; which makes developing on the lapto
p
>difficult.
>Here is the result of "select @.@.Version":
>Microsoft SQL Server 2000 - 8.00.944 (Intel X86) May 19 2004 18:32:44
>Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on Windows
>NT 5.1 (Build 2600: Service Pack 2)|||The error message that I'm getting (from SQL Query Analyzer) is:
"Unable to connect to server [my laptop's server name]"
"Server: Msg 17, Level 16, State 1"
"[Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]SQL Server d
oes not
exist or access denied."
With regard to the event log, I'm assuming that you're refering to the Event
Viewer in Administrative Tools. There's nothing SQL related in there about
a
connection failure.
Again, an existing connection in SQL Query Analyzer runs fine.
"Sue Hoegemeier" wrote:

> What exact errors do you get when you can't connect?
> Did you check the event logs for errors?
> -Sue
> On Wed, 12 Oct 2005 11:21:09 -0700, Andy Rondeau <Andy
> Rondeau@.discussions.microsoft.com> wrote:
>
>|||Could be your NIC - they can switch off in hibernation mode.
Try to telnet to the listening port.
Yes...the Event viewer displays the event logs. I'd look for
network, networking component related issues, not
necessarily just SQL errors related to connection failure.
-Sue
On Mon, 17 Oct 2005 18:28:02 -0700, Andy Rondeau
<AndyRondeau@.discussions.microsoft.com> wrote:
[vbcol=seagreen]
>The error message that I'm getting (from SQL Query Analyzer) is:
>"Unable to connect to server [my laptop's server name]"
>"Server: Msg 17, Level 16, State 1"
>"[Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]SQL Server
does not
>exist or access denied."
>With regard to the event log, I'm assuming that you're refering to the Even
t
>Viewer in Administrative Tools. There's nothing SQL related in there about
a
>connection failure.
>Again, an existing connection in SQL Query Analyzer runs fine.
>"Sue Hoegemeier" wrote:
>|||When I telnet into the server, it connects and the connection stays open for
about a second, and then the connection breaks.
With regard to networking events in the event log, there's some generic
adaptor connected / disconnected around the time that I went into and out of
hibernation, but nothing that would indicate that the adaptor shut down.
"Sue Hoegemeier" wrote:

> Could be your NIC - they can switch off in hibernation mode.
> Try to telnet to the listening port.
> Yes...the Event viewer displays the event logs. I'd look for
> network, networking component related issues, not
> necessarily just SQL errors related to connection failure.
> -Sue
> On Mon, 17 Oct 2005 18:28:02 -0700, Andy Rondeau
> <AndyRondeau@.discussions.microsoft.com> wrote:
>
>|||They don't always come back very well once disconnected so I
would really suspect it has something to do with that.
-Sue
On Tue, 18 Oct 2005 12:20:08 -0700, Andy Rondeau
<AndyRondeau@.discussions.microsoft.com> wrote:
[vbcol=seagreen]
>When I telnet into the server, it connects and the connection stays open fo
r
>about a second, and then the connection breaks.
>With regard to networking events in the event log, there's some generic
>adaptor connected / disconnected around the time that I went into and out o
f
>hibernation, but nothing that would indicate that the adaptor shut down.
>"Sue Hoegemeier" wrote:
>|||But that doesn't solve my problem. I AM making a successful, but short,
connection in telnet after a hibernation, which means that my network adapto
r
is not the culprit.
Is there some way of restarting the SQL server so that it'll accept
connections? Could this be an issue with the client?
"Sue Hoegemeier" wrote:

> They don't always come back very well once disconnected so I
> would really suspect it has something to do with that.
> -Sue
> On Tue, 18 Oct 2005 12:20:08 -0700, Andy Rondeau
> <AndyRondeau@.discussions.microsoft.com> wrote:
>
>|||I just wouldn't use hibernate with SQL Server running. I
wouldn't trust it with SQL anyway
-Sue
On Wed, 19 Oct 2005 10:20:01 -0700, Andy Rondeau
<AndyRondeau@.discussions.microsoft.com> wrote:
[vbcol=seagreen]
>But that doesn't solve my problem. I AM making a successful, but short,
>connection in telnet after a hibernation, which means that my network adapt
or
>is not the culprit.
>Is there some way of restarting the SQL server so that it'll accept
>connections? Could this be an issue with the client?
>"Sue Hoegemeier" wrote:
>

Can't connect to SQL server after hibernating

Hi,
I currently have a development SQL server running locally on my laptop.
After my laptop comes out of hibernation, existing connections to the server,
such as from Query Analyzer, work fine, but I can not make new connections to
the server. I've tried restarting the server through the SQL Server Service
Manager, but it doesn't solve the problem. The only way to be able to
re-establish a connection is to reboot; which makes developing on the laptop
difficult.
Here is the result of "select @.@.Version":
Microsoft SQL Server 2000 - 8.00.944 (Intel X86) May 19 2004 18:32:44
Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on Windows
NT 5.1 (Build 2600: Service Pack 2)
What exact errors do you get when you can't connect?
Did you check the event logs for errors?
-Sue
On Wed, 12 Oct 2005 11:21:09 -0700, Andy Rondeau <Andy
Rondeau@.discussions.microsoft.com> wrote:

>Hi,
>I currently have a development SQL server running locally on my laptop.
>After my laptop comes out of hibernation, existing connections to the server,
>such as from Query Analyzer, work fine, but I can not make new connections to
>the server. I've tried restarting the server through the SQL Server Service
>Manager, but it doesn't solve the problem. The only way to be able to
>re-establish a connection is to reboot; which makes developing on the laptop
>difficult.
>Here is the result of "select @.@.Version":
>Microsoft SQL Server 2000 - 8.00.944 (Intel X86) May 19 2004 18:32:44
>Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on Windows
>NT 5.1 (Build 2600: Service Pack 2)
|||The error message that I'm getting (from SQL Query Analyzer) is:
"Unable to connect to server [my laptop's server name]"
"Server: Msg 17, Level 16, State 1"
"[Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]SQL Server does not
exist or access denied."
With regard to the event log, I'm assuming that you're refering to the Event
Viewer in Administrative Tools. There's nothing SQL related in there about a
connection failure.
Again, an existing connection in SQL Query Analyzer runs fine.
"Sue Hoegemeier" wrote:

> What exact errors do you get when you can't connect?
> Did you check the event logs for errors?
> -Sue
> On Wed, 12 Oct 2005 11:21:09 -0700, Andy Rondeau <Andy
> Rondeau@.discussions.microsoft.com> wrote:
>
>
|||Could be your NIC - they can switch off in hibernation mode.
Try to telnet to the listening port.
Yes...the Event viewer displays the event logs. I'd look for
network, networking component related issues, not
necessarily just SQL errors related to connection failure.
-Sue
On Mon, 17 Oct 2005 18:28:02 -0700, Andy Rondeau
<AndyRondeau@.discussions.microsoft.com> wrote:
[vbcol=seagreen]
>The error message that I'm getting (from SQL Query Analyzer) is:
>"Unable to connect to server [my laptop's server name]"
>"Server: Msg 17, Level 16, State 1"
>"[Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]SQL Server does not
>exist or access denied."
>With regard to the event log, I'm assuming that you're refering to the Event
>Viewer in Administrative Tools. There's nothing SQL related in there about a
>connection failure.
>Again, an existing connection in SQL Query Analyzer runs fine.
>"Sue Hoegemeier" wrote:
|||When I telnet into the server, it connects and the connection stays open for
about a second, and then the connection breaks.
With regard to networking events in the event log, there's some generic
adaptor connected / disconnected around the time that I went into and out of
hibernation, but nothing that would indicate that the adaptor shut down.
"Sue Hoegemeier" wrote:

> Could be your NIC - they can switch off in hibernation mode.
> Try to telnet to the listening port.
> Yes...the Event viewer displays the event logs. I'd look for
> network, networking component related issues, not
> necessarily just SQL errors related to connection failure.
> -Sue
> On Mon, 17 Oct 2005 18:28:02 -0700, Andy Rondeau
> <AndyRondeau@.discussions.microsoft.com> wrote:
>
>
|||They don't always come back very well once disconnected so I
would really suspect it has something to do with that.
-Sue
On Tue, 18 Oct 2005 12:20:08 -0700, Andy Rondeau
<AndyRondeau@.discussions.microsoft.com> wrote:
[vbcol=seagreen]
>When I telnet into the server, it connects and the connection stays open for
>about a second, and then the connection breaks.
>With regard to networking events in the event log, there's some generic
>adaptor connected / disconnected around the time that I went into and out of
>hibernation, but nothing that would indicate that the adaptor shut down.
>"Sue Hoegemeier" wrote:
|||But that doesn't solve my problem. I AM making a successful, but short,
connection in telnet after a hibernation, which means that my network adaptor
is not the culprit.
Is there some way of restarting the SQL server so that it'll accept
connections? Could this be an issue with the client?
"Sue Hoegemeier" wrote:

> They don't always come back very well once disconnected so I
> would really suspect it has something to do with that.
> -Sue
> On Tue, 18 Oct 2005 12:20:08 -0700, Andy Rondeau
> <AndyRondeau@.discussions.microsoft.com> wrote:
>
>
|||I just wouldn't use hibernate with SQL Server running. I
wouldn't trust it with SQL anyway
-Sue
On Wed, 19 Oct 2005 10:20:01 -0700, Andy Rondeau
<AndyRondeau@.discussions.microsoft.com> wrote:
[vbcol=seagreen]
>But that doesn't solve my problem. I AM making a successful, but short,
>connection in telnet after a hibernation, which means that my network adaptor
>is not the culprit.
>Is there some way of restarting the SQL server so that it'll accept
>connections? Could this be an issue with the client?
>"Sue Hoegemeier" wrote: