It's quick and easy to find items in a DataTable through setting the primary key. This method can be used to easily populate a CheckBoxList
DataSet ds = //populate dataset
if(ds != null && ds.Tables.Count > 0)
{
GroupCBL.DataSource = ds;
GroupCBL.DataTextField="textField";
GroupCBL.DataBind();
DataColumn[] dc = new DataColumn[1];
dc[0] = ds.Tables[0].Columns["key"];
ds.Tables[0].PrimaryKey = dc;
foreach(ListItem item in GroupCBL.Items)
{
DataRow row = ds.Tables[0].Rows.Find(item.Value);
item.Selected = Convert.ToBoolean(row["selected"]);
}
}
Thursday, September 25, 2008
Friday, September 12, 2008
Restart a remote machine.
Having problems with the remote machine you are using? Don't want to leave home to head to the office for a restart? Simple cmd can take care of it.
C:\Documents and Settings\unplug1.6>shutdown -m \\Hum -r -y
shutdown is the command you're looking for, "-r" is to specify a restart instead of total shutdown. "-m \\Hum" specifies the remote computer you are trying to restart. Below are a few other arguments.
Usage:
shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]
C:\Documents and Settings\unplug1.6>shutdown -m \\Hum -r -y
shutdown is the command you're looking for, "-r" is to specify a restart instead of total shutdown. "-m \\Hum" specifies the remote computer you are trying to restart. Below are a few other arguments.
No args Display this message (same as -?)
-i Display GUI interface, must be the first option
-l Log off (cannot be used with -m option)
-s Shutdown the computer
-r Shutdown and restart the computer
-a Abort a system shutdown
-m \\computername Remote computer to shutdown/restart/abort
-t xx Set timeout for shutdown to xx seconds
-c "comment" Shutdown comment (maximum of 127 characters)
-f Forces running applications to close without warning
-d [u][p]:xx:yy The reason code for the shutdown
Usage:
shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]
Monday, September 8, 2008
Refreshing the project failed. Unable to retrieve folder information from the server.
I've been working with Visual Studios 2003 and have had the error "Refreshing the project failed. Unable to retrieve folder information from the server." pop up as I'm loading the project. I normally ignore it and go about my business. I finally tired of seeing the pop up and hit the interweb for answers.
To correct the problem simply delete the "VSWebCache" from the "\Documents and Settings\[Username]" directory.
Tuesday, July 8, 2008
Delete the result of an inner join from a SQL table
If you want to delete the result of an inner join from a table, you just need to be redundant...
delete
from userregionlocation
from userregionlocation t
inner join @res r on r.userid=t.userid and r.region=t.region and r.location=t.location
Whatever the result set of:
is what will be deleted from the "userregionlocation" table.
delete
from userregionlocation
from userregionlocation t
inner join @res r on r.userid=t.userid and r.region=t.region and r.location=t.location
Whatever the result set of:
select *
from userregionlocation t
inner join @res r on r.userid=t.userid and r.region=t.region and r.location=t.location
is what will be deleted from the "userregionlocation" table.
Monday, June 30, 2008
Retrieving a file that is stored in a database as an image.
1. Create a "File Server" as an HttpHandler
-Within the web.config, set up a page (filemanager.aspx below) that will handle http requests.
<system.web>
<httpHandlers>
<add verb="*" path="filemanager.aspx" type="Project.FileManagerHttpHandler, DLLName"/>
</httpHandlers>
</system.web>
2. Within the html page, create a hyperlink to the http handler
http post to server: <a href="http://url/fileserver.aspx?uniqueIdentifier">click here</a>
3. Create the class that will handle the http request
public class FileServerHttpHandler : IHttpHandler, IRequiresSessionState
{
// Override the ProcessRequest method.
public void ProcessRequest(HttpContext context)
{
try
{
Guid token = new Guid(context.Request.QueryString.ToString());
BinaryWriter bw;
context.Response.Clear();
using (SqlDataReader dr = SqlHelper.ExecuteReader(DBHelper.ConnectionString, "FileGetByFileToken", token))
{
if (dr != null)
{
if (dr.Read())
{
context.Response.ContentType = dr["filetype"].ToString();
byte[] o = (byte[]) dr["filedata"];
bw = new BinaryWriter(context.Response.OutputStream);
bw.Write(o);
}
dr.Close();
}
}
}
catch (Exception)
{
}
}
// Override the IsReusable property.
public bool IsReusable
{
get { return true; }
}
-Within the web.config, set up a page (filemanager.aspx below) that will handle http requests.
<system.web>
<httpHandlers>
<add verb="*" path="filemanager.aspx" type="Project.FileManagerHttpHandler, DLLName"/>
</httpHandlers>
</system.web>
2. Within the html page, create a hyperlink to the http handler
http post to server: <a href="http://url/fileserver.aspx?uniqueIdentifier">click here</a>
3. Create the class that will handle the http request
public class FileServerHttpHandler : IHttpHandler, IRequiresSessionState
{
// Override the ProcessRequest method.
public void ProcessRequest(HttpContext context)
{
try
{
Guid token = new Guid(context.Request.QueryString.ToString());
BinaryWriter bw;
context.Response.Clear();
using (SqlDataReader dr = SqlHelper.ExecuteReader(DBHelper.ConnectionString, "FileGetByFileToken", token))
{
if (dr != null)
{
if (dr.Read())
{
context.Response.ContentType = dr["filetype"].ToString();
byte[] o = (byte[]) dr["filedata"];
bw = new BinaryWriter(context.Response.OutputStream);
bw.Write(o);
}
dr.Close();
}
}
}
catch (Exception)
{
}
}
// Override the IsReusable property.
public bool IsReusable
{
get { return true; }
}
Saturday, June 28, 2008
Howard Stern on the iPhone
Thanks to the work of Millard Software (www.millardsoftware.com), iPhone owners can now enjoy Howard Stern and the rest of Sirius Satellite Radio through their iPhone!
This is how to set it up:
1. You need to have a jailbroken iPhone, this can be achieved by downloading and installing ZiPhone here.
2. Execute and install the ZiPhone jailbreak onto your iPhone
3. Add the following repository to your Installer:
http://www.millardsoftware.com/files/downloads/usirius/iphone/iphone.xml
4. Select uSirius - iPhone Edition in the Multimedia section.
If you have a Sirius subscription, you enter your credentials and will have Howard Stern and Sirius Radio on your iPhone. If you don't have a subscription yet, you can receive a free three day trial by signing up at Sirius
This is how to set it up:
1. You need to have a jailbroken iPhone, this can be achieved by downloading and installing ZiPhone here.
2. Execute and install the ZiPhone jailbreak onto your iPhone
3. Add the following repository to your Installer:
http://www.millardsoftware.com/files/downloads/usirius/iphone/iphone.xml
more info:
a. click the "installer" which will be on your homescreen
b. click on "Sources" form bottom menu
c. click on "Edit" which will be on the top right of screen
d. click on "Add" which will be on the top left of screen
e. type in the above URL
a. click the "installer" which will be on your homescreen
b. click on "Sources" form bottom menu
c. click on "Edit" which will be on the top right of screen
d. click on "Add" which will be on the top left of screen
e. type in the above URL
4. Select uSirius - iPhone Edition in the Multimedia section.
If you have a Sirius subscription, you enter your credentials and will have Howard Stern and Sirius Radio on your iPhone. If you don't have a subscription yet, you can receive a free three day trial by signing up at Sirius
Monday, April 28, 2008
My Morning Jacket and The Black Keys at Red Rocks Amphitheatre
August 21st 2008, The Black Keys will be opening for My Morning Jacket at Red Rocks Amphitheatre and I have tickets!! It's the only show that the two bands will be playing together on their separate tours. I've never been to Denver, so this will be an all around great trip. Red Rocks, a Hard Rock Cafe I don't have a shot glass from, downtown Denver, and some of the best music around. NICE!!
Subscribe to:
Posts (Atom)