Wednesday, June 18, 2008

SqlDataadapter

//*** don't run more than once ***
String selectCommand = "SELECT EmployeeID FROM Employees";
SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["Sql_ConnectString"]);
SqlDataAdapter da = new SqlDataAdapter(selectCommand, conn);

DataTable table = new DataTable("Employees");
da.FillSchema(table, SchemaType.Source);
da.Fill(table);

conn.Open();
foreach(DataRow row in table.Rows)
{
Int32 employeeId = (Int32)row["EmployeeID"];

String sqlRead = "SELECT Photo FROM Employees WHERE EmployeeID=" + employeeId;
SqlCommand cmdRead = new SqlCommand(sqlRead, conn);

MemoryStream ms = new MemoryStream();
Byte[] image = (Byte[])cmdRead.ExecuteScalar();
ms.Write(image, MSACCESSIMAGEOFFSET, image.Length - MSACCESSIMAGEOFFSET);

String sqlWrite = "UPDATE Employees SET Photo = @Photo WHERE EmployeeID=" + employeeId;
SqlCommand cmdWrite = new SqlCommand(sqlWrite, conn);

//Create parameter for insert command and add to SqlCommand object.
SqlParameter prm = new SqlParameter("@Photo", SqlDbType.VarBinary, ms.ToArray().Length, ParameterDirection.Input, false,
0, 0, null, DataRowVersion.Current, ms.ToArray());
cmdWrite.Parameters.Add(prm);

//Execute query.
cmdWrite.ExecuteNonQuery();
}
conn.Close();
}
}

Query String

Response.Redirect("Welcomepage.aspx?Name=Zam&place=kerala");


Response.Write("My details " +"Name :" +Request.QueryString["Name"]+" "+"Place :"+Request.QueryString["place"]);
Response.Write("Hello" + Request.QueryString["Name"]);

session
------
Session["Name"] = "World hello ";

Response.Redirect("WebForm3.aspx");
2nd page
Response.Write("Name::::" + Session["Name"]);

Tuesday, June 10, 2008

System.Diagnostics.Process.Start

StreamWriter sw;
private void button1_Click(object sender, EventArgs e)
{
sw = File.CreateText("C:\\Zm1.html");
sw.WriteLine("HTML>HEAD>TITLE>/TITLE>/HEAD>");
sw.WriteLine("BODY>H1>HELLO/H1>/BODY>");
sw.WriteLine("/HTML>");
sw.Close();
}

private void button2_Click(object sender, EventArgs e)
{

System.Diagnostics.Process.Start("iexplore", "C:\\Zm1.html");
}
}

Friday, June 6, 2008

deepZoom key strock

public partial class Page : UserControl
{
Point _currentMousePosition = new Point();
public Page()
{
InitializeComponent();
initializeEvents();
}
private void initializeEvents()
{
this.MouseMove += new MouseEventHandler(Page_MouseMove);
this.KeyDown += new KeyEventHandler(Page_KeyDown);
}
void Page_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.W) // zoom in
Zoom(1.2f, _currentMousePosition);
if (e.Key == Key.S) // zoom out
Zoom(0.8f, _currentMousePosition);
}
void Page_MouseMove(object sender, MouseEventArgs e)
{
_currentMousePosition = e.GetPosition(this);
}
private void Zoom(double zoomFactor, Point pointToZoom)
{
Point logicalPoint = dzo.ElementToLogicalPoint(pointToZoom);
dzo.ZoomAboutLogicalPoint(zoomFactor, logicalPoint.X, logicalPoint.Y);
}





}
}

Monday, June 2, 2008

ASP.NET AJAX Extensions 1.0

One of the excellent features of ASP.NET AJAX Extensions 1.0 is the UpdatePanel control. The UpdatePanel control enables partial-page rendering in an ASP.NET Web page asynchronously. The contents of the UpdatePanel control will automatically update when a postback event is invoked. This control does work the same as the MagicAjax.net panel control. The UpdateProgress control is very useful when working with the UpdatePanel control. With an UpdateProgress control, you can show the status during the partial-page rendering of an UpdatePanel