protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "image/jpeg";
// Create a Bitmap instance that's 468x60, and a Graphics instance
const int width = 300, height = 300;
Bitmap objBitmap = new Bitmap(width, height);
Graphics objGraphics = Graphics.FromImage(objBitmap);
// Create a black background for the border
objGraphics.FillRectangle(new SolidBrush(Color.White), 0, 0, width, height);
//DrawPieChart(ref objGraphics);
DrawRectangle(ref objGraphics);
// Save the image to a file
objBitmap.Save(Response.OutputStream, ImageFormat.Jpeg);
// clean up...
objGraphics.Dispose();
objBitmap.Dispose();
}
private void DrawPieChart(ref Graphics objGraphics)
{
// Create location and size of ellipse.
int x = 50;
int y = 20;
int width = 200;
int height = 200;
// Create start and sweep angles.
int startAngle = 0;
int sweepAngle = 45;
SolidBrush objBrush = new SolidBrush(Color.Aqua);
objGraphics.FillPie(new HatchBrush(HatchStyle.Percent50, objBrush.Color), x,
y , width, height, startAngle, sweepAngle);
objBrush.Color = Color.Red;
objGraphics.FillPie(new HatchBrush(HatchStyle.Percent50, objBrush.Color), x,
y, width, height, startAngle+45, sweepAngle);
}
private void DrawRectangle(ref Graphics objGraphics)
{
SolidBrush objBrush = new SolidBrush(Color.Aqua);
objGraphics.FillRectangle(objBrush, 10, 50, 100, 40);
objBrush.Color = Color.Red;
objGraphics.FillRectangle(objBrush, 10, 100, 100, 40);
}
Sunday, September 28, 2008
Thursday, September 25, 2008
ADO.Net with MSDE
This sample will teach you how to install MSDE and conect to msde via ADO.Net
Step 1 : Download MSDE. Click Here to download MSDE.
step 2: open Command prompt. go to the folder where MSDERelA folder resides (generally it will be in C:\MSDERelA).
Step 3: installing MSDE.
type setup SAPWD=[ur password] InstanceName=[InstanceName] SecurityMode=SQL
Step 4: for Getting into MSDE
type osql -E
Step 5: Create database and table
Step 6: Connecting to MSDE via ADO.Net
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Server=.;uid=sa;database=Books";
conn.Open();
SqlCommand comm = new SqlCommand("select * from MyTable", conn);
SqlDataReader dr = comm.ExecuteReader(CommandBehavior.CloseConnection);
if (dr.Read())
{
textBox1.Text = dr["Name"].ToString();
textBox2.Text = dr["Age"].ToString();
}
Step 1 : Download MSDE. Click Here to download MSDE.
step 2: open Command prompt. go to the folder where MSDERelA folder resides (generally it will be in C:\MSDERelA).
Step 3: installing MSDE.
type setup SAPWD=[ur password] InstanceName=[InstanceName] SecurityMode=SQL
Step 4: for Getting into MSDE
type osql -E
Step 5: Create database and table
Step 6: Connecting to MSDE via ADO.Net
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Server=.;uid=sa;database=Books";
conn.Open();
SqlCommand comm = new SqlCommand("select * from MyTable", conn);
SqlDataReader dr = comm.ExecuteReader(CommandBehavior.CloseConnection);
if (dr.Read())
{
textBox1.Text = dr["Name"].ToString();
textBox2.Text = dr["Age"].ToString();
}
Subscribe to:
Posts (Atom)