T
trint
Ok,
Everything connects correctly and loads properly in this
WebApplication. I have four buttons and all work correctly except one
(the NEXT RECORD button). PREVIOUS, FIRST and LAST all work properly.
This identical code works correctly in a windows app.
Please tell me what I am doing wrong.
Here is my connection code:
private void InitializeDataConnection ()
{
// frmStatus frmStatusMessage = new frmStatus();
if (!HasConnected)
{
// frmStatusMessage.Show("Connecting to SQL Server");
// Attempt to connect to SQL server or MSDE
bool IsConnecting = true;
while (IsConnecting)
{
try
{
// Open a Connection
cnn.ConnectionTimeout = 0;
cnn.CommandTimeout = 0;
cnn.Open(Connectionstring, null,null,0);
if (cnn.State != 1)
{
throw new System.Exception("Connection failed.");
}
if (!HasConnected)
{
// frmStatusMessage.Close();
}
IsConnecting = false;
HasConnected = true;
}
catch
{
if (Connectionstring == SQL_CONNECTION_STRING)
{
// Couldn't connect to SQL server. Now try MSDE
// Connectionstring = MSDE_CONNECTION_STRING;
// frmStatusMessage.Show("Connecting to MSDE");
}
else
{
// Unable to connect to SQL Server or MSDE
// frmStatusMessage.Close();
// MessageBox.Show("To run this sample you must have SQL
Server ot MSDE with the Northwind database installed. For instructions
on installing MSDE, view the Readme file." + MessageBoxIcon.Warning +
"SQL Server/MSDE not found");
// Quit program if neither connection method was successful.
// Application.Exit();
}
}
}
}
// }
// Build SQL statement.
// string strSQL = "SELECT * " +
// "FROM member " ;
string strSQL = "SELECT t1.member_id, t1.first_name, t1.last_name "
+
"FROM member t1 " ;
rs.ActiveConnection = cnn;
rs.CursorType = CursorTypeEnum.adOpenStatic;
rs.Open(strSQL,cnn,ADODB.CursorTypeEnum.adOpenDynamic,ADODB.LockTypeEnum.adLockOptimistic,0);
rs.MoveFirst();
}
and here is the code giving the problem:
private void Button2_Click(object sender, System.EventArgs e)
{
// this code is used to prevent going to EOF
if (!rs.EOF)
{
rs.MoveNext();
if (rs.EOF)
{
rs.MovePrevious();
}
PopulateSimpleNavigationForm();
}
}
Any help is appreciated.
Thanks,
Trint
Everything connects correctly and loads properly in this
WebApplication. I have four buttons and all work correctly except one
(the NEXT RECORD button). PREVIOUS, FIRST and LAST all work properly.
This identical code works correctly in a windows app.
Please tell me what I am doing wrong.
Here is my connection code:
private void InitializeDataConnection ()
{
// frmStatus frmStatusMessage = new frmStatus();
if (!HasConnected)
{
// frmStatusMessage.Show("Connecting to SQL Server");
// Attempt to connect to SQL server or MSDE
bool IsConnecting = true;
while (IsConnecting)
{
try
{
// Open a Connection
cnn.ConnectionTimeout = 0;
cnn.CommandTimeout = 0;
cnn.Open(Connectionstring, null,null,0);
if (cnn.State != 1)
{
throw new System.Exception("Connection failed.");
}
if (!HasConnected)
{
// frmStatusMessage.Close();
}
IsConnecting = false;
HasConnected = true;
}
catch
{
if (Connectionstring == SQL_CONNECTION_STRING)
{
// Couldn't connect to SQL server. Now try MSDE
// Connectionstring = MSDE_CONNECTION_STRING;
// frmStatusMessage.Show("Connecting to MSDE");
}
else
{
// Unable to connect to SQL Server or MSDE
// frmStatusMessage.Close();
// MessageBox.Show("To run this sample you must have SQL
Server ot MSDE with the Northwind database installed. For instructions
on installing MSDE, view the Readme file." + MessageBoxIcon.Warning +
"SQL Server/MSDE not found");
// Quit program if neither connection method was successful.
// Application.Exit();
}
}
}
}
// }
// Build SQL statement.
// string strSQL = "SELECT * " +
// "FROM member " ;
string strSQL = "SELECT t1.member_id, t1.first_name, t1.last_name "
+
"FROM member t1 " ;
rs.ActiveConnection = cnn;
rs.CursorType = CursorTypeEnum.adOpenStatic;
rs.Open(strSQL,cnn,ADODB.CursorTypeEnum.adOpenDynamic,ADODB.LockTypeEnum.adLockOptimistic,0);
rs.MoveFirst();
}
and here is the code giving the problem:
private void Button2_Click(object sender, System.EventArgs e)
{
// this code is used to prevent going to EOF
if (!rs.EOF)
{
rs.MoveNext();
if (rs.EOF)
{
rs.MovePrevious();
}
PopulateSimpleNavigationForm();
}
}
Any help is appreciated.
Thanks,
Trint