WebReference News Gennaio 30th, 2008
Want to make money from blogging? Check out this article which explores the options open to you as a blogger, as well as the different revenue and affiliate programs available. By John Matthew. 1206
CodeKeep C# Feed Gennaio 30th, 2008
Description: Calculates the md5 hash of a file.
Link:
http://www.codekeep.net/snippets/a42fa74c-c299-414d-80d9-515cc93596aa.aspxSystem.IO.FileStream fs = new FileStream(@"C:\temp\test.xml", FileMode.Open, FileAccess.Read);
System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
byte[] bytes = md5.ComputeHash(fs);
StringBuilder sBuilder = new StringBuilder();
for (int i = 0; i < bytes.Length; i++)
{
sBuilder.Append(bytes[i].ToString("x2"));
}
CodeKeep C# Feed Gennaio 30th, 2008
Description: Rebinding/refreshing of DataGridView after Inserting, Deleteng and Updating of data.
Link:
http://www.codekeep.net/snippets/5292429f-3f95-45ed-9e9c-89c2d208c955.aspxprivate void FillDataSet()
{
String selectcommand = "SELECT EmployeeID, LastName, FirstName, MiddleName, Age, Birthday, MobileNumber, EmailAddress FROM Test";
GetData(selectcommand);
}
private void GetData(string selectCommand)
{
try
{
// Create a new data adapter based on the specified query.
dataAdapter = new SqlDataAdapter(selectCommand, connection());
// Create a command builder to generate SQL update, insert, and
// delete commands based on selectCommand. These are used to
// update the database.
SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);
// Populate a new data table and bind it to the BindingSource.
DataTable table = new DataTable();
table.Locale = System.Globalization.CultureInfo.InvariantCulture;
dataAdapter.Fill(table);
dgvEmployee.DataSource = table;
// Resize the DataGridView columns to fit the newly loaded content.
//dgvEmployee.AutoResizeColumns(
// DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
}
catch (SqlException)
{
MessageBox.Show("To run this example, replace the value of the " +
"connectionString variable with a connection string that is " +
"valid for your system.");
}
}