Click here to Skip to main content
15,915,867 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionPass string to error page Pin
mail57235219-Apr-07 3:45
mail57235219-Apr-07 3:45 
AnswerRe: Pass string to error page Pin
Tarakeshwar Reddy19-Apr-07 3:55
professionalTarakeshwar Reddy19-Apr-07 3:55 
GeneralRe: Pass string to error page Pin
mail57235219-Apr-07 13:37
mail57235219-Apr-07 13:37 
QuestionHyperlinks in datagrid! Pin
nclauder19-Apr-07 3:27
nclauder19-Apr-07 3:27 
AnswerRe: Hyperlinks in datagrid! Pin
kubben19-Apr-07 5:32
kubben19-Apr-07 5:32 
GeneralRe: Hyperlinks in datagrid! Pin
nclauder19-Apr-07 19:24
nclauder19-Apr-07 19:24 
QuestionExport Excel Problem [modified] Pin
Karthik Kommandi19-Apr-07 3:01
Karthik Kommandi19-Apr-07 3:01 
QuestionProblem with DataReader and SQL Express Pin
kallileo19-Apr-07 2:15
kallileo19-Apr-07 2:15 
Sub Page_Load(ByVal Sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

If Not Page.IsPostBack Then
Dim SQLconn As New SqlConnection("Server=(local)\SQLExpress;Initial Catalog=Test;Integrated Security=True")
SQLconn.Open()
Dim Query As String = "SELECT rawvalue FROM Device1 WHERE device = 'Channel1'"
Dim SelectCmd As New SqlCommand(Query, SQLconn)
Dim result As Boolean

SQLconn.Open()
Dim myDataReader As SqlDataReader
myDataReader = SelectCmd.ExecuteReader()
result = myDataReader.GetBoolean(0)
SQLconn.Close()

ChangeButton(result)
End If
End Sub

Sub ChangeButton(ByVal Status As Boolean)
If Status Then
OnOff.Text = "Press to Close"
Label1.Text = "ON"
Label1.BackColor = Drawing.Color.Green
Else
OnOff.Text = "Press To Open"
Label1.Text = "OFF"
Label1.BackColor = Drawing.Color.Red
End If
End Sub



I have this code to change some properties of a label and a button. The problem is that I get and error while debbugging this in Visual Web Developer.
The error is:
"The connection was not closed. The connection's current state is open."

The problem is in line 21 "SQLconn.Open()"

Stack Trace:

[InvalidOperationException: The connection was not closed. The connection's current state is open.]
System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +56
System.Data.SqlClient.SqlConnection.Open() +229
ASP.mapurls_p2_aspx.Page_Load(Object Sender, EventArgs e) in C:\Websites\Project\MapUrls\p2.aspx:21
System.Web.UI.Control.OnLoad(EventArgs e) +88
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3034


Thanks!
AnswerRe: Problem with DataReader and SQL Express Pin
Paddy Boyd19-Apr-07 2:24
Paddy Boyd19-Apr-07 2:24 
GeneralRe: Problem with DataReader and SQL Express Pin
kallileo19-Apr-07 2:55
kallileo19-Apr-07 2:55 
GeneralRe: Problem with DataReader and SQL Express Pin
Paddy Boyd19-Apr-07 3:03
Paddy Boyd19-Apr-07 3:03 
GeneralRe: Problem with DataReader and SQL Express Pin
kallileo19-Apr-07 3:09
kallileo19-Apr-07 3:09 
GeneralRe: Problem with DataReader and SQL Express Pin
Paddy Boyd19-Apr-07 3:25
Paddy Boyd19-Apr-07 3:25 
GeneralRe: Problem with DataReader and SQL Express Pin
kallileo19-Apr-07 3:35
kallileo19-Apr-07 3:35 
Questionpopup doubt Pin
saravanan0519-Apr-07 2:15
saravanan0519-Apr-07 2:15 
AnswerRe: popup doubt Pin
rama charan19-Apr-07 5:51
rama charan19-Apr-07 5:51 
QuestionHelp regarding interaction between flash and asp.net Pin
anu8119-Apr-07 2:04
anu8119-Apr-07 2:04 
QuestionASP.NET Connection with sql server 2005. Pin
Sujit Mandal19-Apr-07 1:55
Sujit Mandal19-Apr-07 1:55 
AnswerRe: ASP.NET Connection with sql server 2005. Pin
Sujit Mandal19-Apr-07 2:26
Sujit Mandal19-Apr-07 2:26 
GeneralRe: ASP.NET Connection with sql server 2005. Pin
Arun.Immanuel19-Apr-07 2:54
Arun.Immanuel19-Apr-07 2:54 
QuestionDropdown getting Flickered, in UpdatePanel Async postback Pin
vvijaykrishna19-Apr-07 1:27
vvijaykrishna19-Apr-07 1:27 
QuestionAjax with Asp.net [modified] Pin
iamdking19-Apr-07 1:26
iamdking19-Apr-07 1:26 
AnswerRe: Ajax with Asp.net Pin
Atif Ali Bhatti19-Apr-07 1:43
Atif Ali Bhatti19-Apr-07 1:43 
GeneralRe: Ajax with Asp.net Pin
iamdking19-Apr-07 1:56
iamdking19-Apr-07 1:56 
GeneralRe: Ajax with Asp.net Pin
Atif Ali Bhatti19-Apr-07 2:23
Atif Ali Bhatti19-Apr-07 2:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.