D
Dan Bass
Environment
C#, Asp.Net 2.0, Windows 2000 Server
Problem
I'm trying to enumerate all the names in the global contacts on the exchange
server using CDO / ADO / (whatever I can).
In writing an ASP.Net support ticket application, I want to populate the
list of "Who reported this ticket" with names from the global contacts.
An extension of this would then be to allow the user to add a person to the
global contact via the web page, should they not exist in the contacts list.
To start with, I'm writing a basic windows application with one textbox as
the input providing the URL to get the contacts from, and one text box as
the output to put any contacts names I find into. I compile this application
then try to run it on the exchange server, but get an error saying the
"Bookmark is invalid" the first (and every time) MoveNext is called on the
result record set.
I've looked into this error and some articles on the web relate it to
exchange, recommending a machine restart. I've done that the problem
persists. There's no errors with this exchange server with Outlook for
example, so I'm hard pressed to think it's not something with my
application.
Any help or guidance would be appreciated, and yes, I've seen the articles
google gives you on "enumerating contacts with c#" (terrible IMO), and have
read the microsoft articles.
Code
string url = urlTextBox.Text;
ADODB.Connection con = null;
ADODB.Recordset rs = null;
try
{
// create the connection
con = new ADODB.Connection();
con.Provider = "exoledb.datasource";
con.Open(url, "", "", 0);
// build SQL query
string SqlQuery = "SELECT * FROM \"" + url + "\"";
// build the record set object
rs = new ADODB.Recordset();
rs.Open(SqlQuery,
con,
ADODB.CursorTypeEnum.adOpenDynamic,
ADODB.LockTypeEnum.adLockOptimistic,
0);
// enumarate through the retrieved record set
for (; !rs.EOF; rs.MoveNext()) // <<<--- "Bookmark is invalid"
exception
{
usernamesTextBox.Text +=
rs.Fields["urn:schemas:contacts:givenName"].Value.ToString() +"\r\n";
}
}
catch (Exception ex)
{
MessageBox.Show("OOPS!\r\n------\r\n\r\n" + ex.ToString());
}
finally
{
if (rs != null && rs.State ==
(int)ADODB.ObjectStateEnum.adStateOpen)
rs.Close();
if (con != null && con.State ==
(int)ADODB.ObjectStateEnum.adStateOpen)
con.Close();
}
C#, Asp.Net 2.0, Windows 2000 Server
Problem
I'm trying to enumerate all the names in the global contacts on the exchange
server using CDO / ADO / (whatever I can).
In writing an ASP.Net support ticket application, I want to populate the
list of "Who reported this ticket" with names from the global contacts.
An extension of this would then be to allow the user to add a person to the
global contact via the web page, should they not exist in the contacts list.
To start with, I'm writing a basic windows application with one textbox as
the input providing the URL to get the contacts from, and one text box as
the output to put any contacts names I find into. I compile this application
then try to run it on the exchange server, but get an error saying the
"Bookmark is invalid" the first (and every time) MoveNext is called on the
result record set.
I've looked into this error and some articles on the web relate it to
exchange, recommending a machine restart. I've done that the problem
persists. There's no errors with this exchange server with Outlook for
example, so I'm hard pressed to think it's not something with my
application.
Any help or guidance would be appreciated, and yes, I've seen the articles
google gives you on "enumerating contacts with c#" (terrible IMO), and have
read the microsoft articles.
Code
string url = urlTextBox.Text;
ADODB.Connection con = null;
ADODB.Recordset rs = null;
try
{
// create the connection
con = new ADODB.Connection();
con.Provider = "exoledb.datasource";
con.Open(url, "", "", 0);
// build SQL query
string SqlQuery = "SELECT * FROM \"" + url + "\"";
// build the record set object
rs = new ADODB.Recordset();
rs.Open(SqlQuery,
con,
ADODB.CursorTypeEnum.adOpenDynamic,
ADODB.LockTypeEnum.adLockOptimistic,
0);
// enumarate through the retrieved record set
for (; !rs.EOF; rs.MoveNext()) // <<<--- "Bookmark is invalid"
exception
{
usernamesTextBox.Text +=
rs.Fields["urn:schemas:contacts:givenName"].Value.ToString() +"\r\n";
}
}
catch (Exception ex)
{
MessageBox.Show("OOPS!\r\n------\r\n\r\n" + ex.ToString());
}
finally
{
if (rs != null && rs.State ==
(int)ADODB.ObjectStateEnum.adStateOpen)
rs.Close();
if (con != null && con.State ==
(int)ADODB.ObjectStateEnum.adStateOpen)
con.Close();
}