Showing posts with label state. Show all posts
Showing posts with label state. Show all posts

Wednesday, March 28, 2012

The bitwise combination of the DataControlRowState values

Hi,

I want to use the switch loop for the state of a gridrow:

switch (gvr.RowState)
{
case DataControlRowState.Selected:
case DataControlRowState.Alternate:
case DataControlRowState.Normal:
// doing something
break;
case DataControlRowState.Edit:
// doing something
break;
case DataControlRowState.Insert:
// doing something
break;
}

But because the row can be both selected and normal (bitwise combination), the rowstate is none of them. when I output the rowstate to the page it is for example "Selected, Normal". How can I add a case value for a bitwise combination?

KaaNThis will work:

case DataControlRowState.Selected | DataControlRowState.Normal:

Monday, March 26, 2012

The connections current state is Connecting.

Only on one page that I got in my project do I get this error:

ExecuteReader requires an open and available Connection. The connection's current state is Connecting.

Shouldn't the connection object automatically wait until it's open and then move on ?

The code:


Dim SQL As String, MyRead As OleDb.OleDbDataReader

Try
MyConn = New OleDb.OleDbConnection(ConfigurationSettings.AppSettings("ConnectionString"))
If MyConn.State <> ConnectionState.Open Then
MyConn.Open()
End If
Try
SQL = "SELECT * FROM tbl_table"
Dim MyCMD As New OleDb.OleDbCommand(SQL, MyConn)
MyRead = MyCMD.ExecuteReader
MyCMD.Dispose()
If Not MyRead.Read = False Then
LN = MyRead.GetString(0)
FN = MyRead.GetString(1)
EML = MyRead.GetString(2)
PHN = MyRead.GetString(3)
ADD = MyRead.GetString(4)
CITY = MyRead.GetString(5)
STATE = MyRead.GetString(6)
ZIP = MyRead.GetString(7)
COUNTRY = MyRead.GetString(8)
FAX = MyRead.GetString(9)
CELL = MyRead.GetString(10)
URL = MyRead.GetString(11)
COMPANY = MyRead.GetString(12)
End If
Catch ex As Exception
Call READ_EXCEPTION(ex)
Finally
MyRead.Close()
End Try
Catch ex As Exception
Call READ_EXCEPTION(ex)
Finally
MyConn.Dispose()
End Try

Have you stepped through the code to find out if it's executing the myConn.Open method?
Not yet, the thing is that I can just refresh the page and it will start loading normally, it will do this completely at random.

The connection was not closed. The connections current state is open

I'm not sure why I am still getting this connection error

www.photopizzaz.biz/allcode.txt

resolved it, please disregard this thread.


Okay, But you might want to remove that code for security reasons(from the server).