> Hi all
>
[quoted text clipped - 11 lines]
> Thanks,
> Bill
anyone?
> I want to use an OnLoad command to trigger a search of a database to
> see if the user's login is there.
Presumably, you mean the Page_Load method...?
> I then want to set a variable which indicates if the user was found.
OK.
> Do I use a SelectCommand in the SqlDataSource and reference
> User.Identity.Name?
If that is how your users are referenced in your database... You could also
use a stored procedure...
> Then how do I use the OnLoad command to trigger the search?
protected void Page_Load(object sender, EventArgs e)
{
strConnectionString = "<connection string>";
strSQL = "SELECT * FROM MyUsers WHERE UserID = '" + User.Identity.Name +
"'";
using (SqlConnection objSqlConnection = new
SqlConnection(mstrConnectionString))
{
objSqlConnection.Open();
using (SqlCommand objSqlCommand = new SqlCommand(pstrSQL,
objSqlConnection))
{
using (SqlDataAdapter objDA = new SqlDataAdapter(objSqlCommand))
{
using (DataSet objDataSet = new DataSet())
{
objDA.Fill(objDataSet);
if (objDataSet.Tables[0].Rows.Count > 0)
{
// get any additional user details...
Session["UserExists"] = true;
}
}
}
}
}
}
The above is merely one of several methods you could use, and is not
particularly robust, but it should get you started...

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
Bill - 11 Oct 2007 16:42 GMT
> > I want to use an OnLoad command to trigger a search of a database to
> > see if the user's login is there.
[quoted text clipped - 49 lines]
> Mark Rae
> ASP.NET MVPhttp://www.markrae.net
Thanks, Mark. This should get me started.
Does the DataSet and DataAdapter code create the DataSet and
DataAdapters on their own? Or do I need to drag those elements in from
the toolbox and link them?
Mark Rae [MVP] - 11 Oct 2007 19:26 GMT
> Does the DataSet and DataAdapter code create the DataSet and
> DataAdapters on their own?
Yes.
> Or do I need to drag those elements in from the toolbox and link them?
No. FWIW, I never use the ToolBox for anything at all...

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net