| Home | Forums | Reviews | Articles | Register |
![]() |
| Thread Tools |
Rating:
|
|
|
|
| |
|
=?Utf-8?B?U29tbmF0aCBLdW5kdQ==?=
Guest
Posts: n/a
|
How about checking the conncetion before opening it..
Try the follwing code :- SqlConnection cn = new SqlConnection if(cn.State !=ConnectionState.Open) cn.Open() This should have been done anyway...And this is a good practice to check the connection state always. "ST" wrote: > This is my other error when I click on Immunoflourescence. I believe this is > related to the other error I just posted (Input string was not in a correct > format.) Please let me know if you have any suggestions! Thanks! > > > > The connection is already Open (state=Open). > Description: An unhandled exception occurred during the execution of the > current web request. Please review the stack trace for more information about > the error and where it originated in the code. > > Exception Details: System.InvalidOperationException: The connection is > already Open (state=Open). > > Source Error: > > > Line 132: End If > Line 133: > Line 134: connStr.Open() > Line 135: Try > Line 136: c.ExecuteNonQuery() > > > *******MY CODE******** > Imports System.Data.SqlClient > > Public Class proteindiagnosis1 > Inherits System.Web.UI.Page > > #Region " Web Form Designer Generated Code " > > 'This call is required by the Web Form Designer. > <System.Diagnostics.DebuggerStepThrough()> Private Sub > InitializeComponent() > > End Sub > Protected WithEvents Label1 As System.Web.UI.WebControls.Label > Protected WithEvents Label2 As System.Web.UI.WebControls.Label > Protected WithEvents txtDate As System.Web.UI.WebControls.TextBox > Protected WithEvents Label3 As System.Web.UI.WebControls.Label > Protected WithEvents ddlPM As System.Web.UI.WebControls.DropDownList > Protected WithEvents Label4 As System.Web.UI.WebControls.Label > Protected WithEvents ddlBlot_DR As System.Web.UI.WebControls.DropDownList > Protected WithEvents Label5 As System.Web.UI.WebControls.Label > Protected WithEvents Label6 As System.Web.UI.WebControls.Label > Protected WithEvents ddlBlot_DD As System.Web.UI.WebControls.DropDownList > Protected WithEvents Label7 As System.Web.UI.WebControls.Label > Protected WithEvents txtBlot_DSize As System.Web.UI.WebControls.TextBox > Protected WithEvents Label8 As System.Web.UI.WebControls.Label > Protected WithEvents txtBlot_DQ As System.Web.UI.WebControls.TextBox > Protected WithEvents Label9 As System.Web.UI.WebControls.Label > Protected WithEvents txtBlot_DStain As System.Web.UI.WebControls.TextBox > Protected WithEvents Label10 As System.Web.UI.WebControls.Label > Protected WithEvents ddlBlot_DF As System.Web.UI.WebControls.DropDownList > Protected WithEvents Label12 As System.Web.UI.WebControls.Label > Protected WithEvents Label11 As System.Web.UI.WebControls.Label > Protected WithEvents ddlFlu_DR As System.Web.UI.WebControls.DropDownList > Protected WithEvents Label13 As System.Web.UI.WebControls.Label > Protected WithEvents ddlFlu_DD As System.Web.UI.WebControls.DropDownList > Protected WithEvents Label14 As System.Web.UI.WebControls.Label > Protected WithEvents ddlFlu_DRV As System.Web.UI.WebControls.DropDownList > Protected WithEvents Label15 As System.Web.UI.WebControls.Label > Protected WithEvents ddlFlu_DA1 As System.Web.UI.WebControls.DropDownList > Protected WithEvents Label16 As System.Web.UI.WebControls.Label > Protected WithEvents ddlFlu_DA2 As System.Web.UI.WebControls.DropDownList > Protected WithEvents Label17 As System.Web.UI.WebControls.Label > Protected WithEvents ddlFlu_MR As System.Web.UI.WebControls.DropDownList > Protected WithEvents Label18 As System.Web.UI.WebControls.Label > Protected WithEvents ddlFlu_MA1 As System.Web.UI.WebControls.DropDownList > Protected WithEvents Label19 As System.Web.UI.WebControls.Label > Protected WithEvents ddlFlu_MA2 As System.Web.UI.WebControls.DropDownList > Protected WithEvents Label20 As System.Web.UI.WebControls.Label > Protected WithEvents ddlFlu_AR As System.Web.UI.WebControls.DropDownList > Protected WithEvents Button1 As System.Web.UI.WebControls.Button > Protected WithEvents Button2 As System.Web.UI.WebControls.Button > Protected WithEvents tblImmunoblot As System.Web.UI.WebControls.Table > Protected WithEvents tblImmunoflo As System.Web.UI.WebControls.Table > Protected WithEvents Form1 As System.Web.UI.HtmlControls.HtmlForm > Protected WithEvents txtError As System.Web.UI.WebControls.Label > Protected WithEvents btnSubmit As System.Web.UI.WebControls.Button > Protected WithEvents RegularExpressionValidator2 As > System.Web.UI.WebControls.RegularExpressionValidator > Protected WithEvents Label21 As System.Web.UI.WebControls.Label > Protected WithEvents txtNotes As System.Web.UI.WebControls.TextBox > Protected WithEvents Label22 As System.Web.UI.WebControls.Label > Protected WithEvents btnBack As System.Web.UI.WebControls.Button > Protected WithEvents btnMain As System.Web.UI.WebControls.Button > Protected WithEvents btnLogOff As System.Web.UI.WebControls.Button > > 'NOTE: The following placeholder declaration is required by the Web Form > Designer. > 'Do not delete or move it. > Private designerPlaceholderDeclaration As System.Object > > Private Sub Page_Init(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles MyBase.Init > 'CODEGEN: This method call is required by the Web Form Designer > 'Do not modify it using the code editor. > InitializeComponent() > End Sub > > #End Region > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles MyBase.Load > 'Put user code to initialize the page here > > End Sub > > Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles btnSubmit.Click > Dim connStr As New SqlConnection(Application("cn")) > Dim c As New SqlCommand > 'Either UPDATE or INSERT the information > If Session("update") = "True" Then > c.CommandText = "UPDATE PROTEIN_DIAGNOSIS SET DIAG_DATE=@date, > DYST_RESULT=@DYST_RESULT, DYST_DIAGNOSIS=@DYST_DIAGNOSIS, > DYST_SIZE=@DYST_SIZE, DYST_QUANTITY=@DYST_QUANTITY, > DYST_STAINING=@DYST_STAINING, DYST_ANTIBODY_1=@DYST_ANTIBODY_1, > DYST_ANTIBODY_2=@DYST_ANTIBODY_2, DYST_REVERTANTS=@DYST_REVERTANTS, > MEROSIN_RESULT=@MEROSIN_RESULT, MEROSIN_ANTIBODY_1=@MEROSIN_ANTIBODY_1, > MEROSIN_ANTIBODY_2=@MEROSIN_ANTIBODY_2, ALPHA_SAC_RESULT=@ALPHA_SAC_RESULT, > DYSFERLIN_RESULT=@DYSFERLIN_RESULT, NOTES=@NOTES where procedure_Id = '" & > Session("Procedure_ID") & "' AND protein_diag_method = '" & > ddlPM.SelectedValue & "'" > Session("update") = "False" > Else > c.CommandText = "INSERT INTO PROTEIN_DIAGNOSIS (PROCEDURE_ID, > PROTEIN_DIAG_METHOD, DIAG_DATE, DYST_RESULT," > c.CommandText &= " DYST_DIAGNOSIS, DYST_SIZE, DYST_QUANTITY, > DYST_STAINING, DYSFERLIN_RESULT," > c.CommandText &= " DYST_REVERTANTS, DYST_ANTIBODY_1, > DYST_ANTIBODY_2, MEROSIN_RESULT, MEROSIN_ANTIBODY_1, MEROSIN_ANTIBODY_2, > ALPHA_SAC_RESULT, NOTES)" > c.CommandText &= " VALUES (@Proc, @Method, @Date, @DYST_RESULT, > @DYST_DIAGNOSIS, @DYST_SIZE, @DYST_QUANTITY, @DYST_STAINING, > @DYSFERLIN_RESULT," > c.CommandText &= " @DYST_REVERTANTS, @DYST_ANTIBODY_1, > @DYST_ANTIBODY_2, @MEROSIN_RESULT, @MEROSIN_ANTIBODY_1, @MEROSIN_ANTIBODY_2, > @ALPHA_SAC_RESULT, @NOTES)" > End If > c.Connection = connStr > c.CommandType = CommandType.Text > > 'Biopsy Pathology Information > c.Parameters.Add("@Proc", SqlDbType.Int).Value = > Session("Procedure_ID") > c.Parameters.Add("@Method", SqlDbType.Char, 20).Value = > ddlPM.SelectedValue > c.Parameters.Add("@Date", SqlDbType.DateTime).Value = txtDate.Text > c.Parameters.Add("@Notes", SqlDbType.VarChar, 255).Value = > txtNotes.Text > If ddlPM.SelectedValue = "IMMUNOBLOT" Then > c.Parameters.Add("@DYST_RESULT", SqlDbType.VarChar, 20).Value = > ddlBlot_DR.SelectedValue > c.Parameters.Add("@DYST_DIAGNOSIS", SqlDbType.VarChar, 20).Value > = ddlBlot_DD.SelectedValue > c.Parameters.Add("@DYST_SIZE", SqlDbType.Int).Value = > txtBlot_DSize.Text > c.Parameters.Add("@DYST_QUANTITY", SqlDbType.Int).Value = > txtBlot_DQ.Text > c.Parameters.Add("@DYST_STAINING", SqlDbType.Int).Value = > txtBlot_DStain.Text > c.Parameters.Add("@DYSFERLIN_RESULT", SqlDbType.VarChar, > 20).Value = ddlBlot_DF.SelectedValue > c.Parameters.Add("@DYST_REVERTANTS", SqlDbType.VarChar, 3).Value > = "1" > c.Parameters.Add("@DYST_ANTIBODY_1", SqlDbType.VarChar, > 20).Value = "1" > c.Parameters.Add("@DYST_ANTIBODY_2", SqlDbType.VarChar, > 20).Value = "1" > c.Parameters.Add("@MEROSIN_RESULT", SqlDbType.VarChar, 20).Value > = "1" > c.Parameters.Add("@MEROSIN_ANTIBODY_1", SqlDbType.VarChar, > 20).Value = "1" > c.Parameters.Add("@MEROSIN_ANTIBODY_2", SqlDbType.VarChar, > 20).Value = "1" > c.Parameters.Add("@ALPHA_SAC_RESULT", SqlDbType.VarChar, > 20).Value = "1" > End If > If ddlPM.SelectedValue = "IMMUNOFLO" Then > c.Parameters.Add("@DYST_RESULT", SqlDbType.VarChar, 20).Value = > ddlFlu_DR.SelectedValue > c.Parameters.Add("@DYST_DIAGNOSIS", SqlDbType.VarChar, 20).Value > = ddlFlu_DD.SelectedValue > c.Parameters.Add("@DYST_SIZE", SqlDbType.Int).Value = DBNull.Value > c.Parameters.Add("@DYST_QUANTITY", SqlDbType.Int).Value = > DBNull.Value > c.Parameters.Add("@DYST_STAINING", SqlDbType.Int).Value = > DBNull.Value > c.Parameters.Add("@DYSFERLIN_RESULT", SqlDbType.VarChar, > 20).Value = "1" > c.Parameters.Add("@DYST_REVERTANTS", SqlDbType.VarChar, 3).Value > = ddlFlu_DRV.SelectedValue > c.Parameters.Add("@DYST_ANTIBODY_1", SqlDbType.VarChar, > 20).Value = ddlFlu_DA1.SelectedValue > c.Parameters.Add("@DYST_ANTIBODY_2", SqlDbType.VarChar, > 20).Value = ddlFlu_DA2.SelectedValue > c.Parameters.Add("@MEROSIN_RESULT", SqlDbType.VarChar, 20).Value > = ddlFlu_MR.SelectedValue > c.Parameters.Add("@MEROSIN_ANTIBODY_1", SqlDbType.VarChar, > 20).Value = ddlFlu_MA1.SelectedValue > c.Parameters.Add("@MEROSIN_ANTIBODY_2", SqlDbType.VarChar, > 20).Value = ddlFlu_MA2.SelectedValue > c.Parameters.Add("@ALPHA_SAC_RESULT", SqlDbType.VarChar, > 20).Value = ddlFlu_AR.SelectedValue > End If > > connStr.Open() > Try > c.ExecuteNonQuery() > Catch myerr As SqlException > txtError.Visible = True > txtError.Text = myerr.Message > Finally > connStr.Close() > End Try > 'txtError.Visible = True > 'txtError.Text = Session("Procedure_ID") > > End Sub 'Page_Load > > > > > > |
|
||
|
||||
![]() |
| Thread Tools | |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ExecuteReader requires an open and available Connection. The connection's current state is Open, Executing. | fniles | Microsoft VB .NET | 7 | 18th Apr 2007 02:51 AM |
| ExecuteScalar requires an open and available Connection. The connection's current state is Open, Executing. | hasmukh4u@gmail.com | Microsoft ADO .NET | 0 | 2nd Feb 2007 02:30 PM |
| the connection is already open (state=open) | =?Utf-8?B?QW5keQ==?= | Microsoft ADO .NET | 3 | 3rd Jun 2005 06:54 PM |
| The connection is already Open (state=Open)". when it goes to SaveTOSQL. | =?Utf-8?B?ZGFidXNrb2w=?= | Microsoft ADO .NET | 1 | 29th Mar 2004 01:36 PM |
| The connection is already Open (state=Open)". when it goes to SaveTOSQL. | =?Utf-8?B?ZGFidXNrb2w=?= | Microsoft C# .NET | 0 | 29th Mar 2004 09:51 AM |
Powered by vBulletin®. Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2010, Crawlability, Inc. |





