See the snippet below, how it works!!
SqlConnection Conn = new SqlConnection("<>");
SqlCommand Cmd = new SqlCommand("select docobject, filetype,docname from documents where docid = 23", Conn);
Cmd.CommandType = CommandType.Text;
Conn.Open();
SqlDataReader Reader = Cmd.ExecuteReader(CommandBehavior.CloseConnection);
//
string DocumentName = null;
FileStream FStream = null;
BinaryWriter BWriter = null;
//
//
//
byte[] Binary = null;
const int ChunkSize = 100;
int SizeToWrite = 0;
MemoryStream MStream = null;
//
while (Reader.Read())
{
DocumentName = Reader["docname"].ToString();
// Create a file to hold the output.
FStream = new FileStream(@"c:\" + DocumentName, FileMode.OpenOrCreate, FileAccess.Write);
BWriter = new BinaryWriter(FStream);
Binary = (Reader["docobject"]) as byte[];
SizeToWrite = ChunkSize;
MStream = new MemoryStream(Binary);
//
for (int i = 0; i < Binary.GetUpperBound(0) - 1; i = i + ChunkSize)
{
if (i + ChunkSize >= Binary.Length) SizeToWrite = Binary.Length - i;
byte[] Chunk = new byte[SizeToWrite];
MStream.Read(Chunk, 0, SizeToWrite);
BWriter.Write(Chunk);
BWriter.Flush();
}
BWriter.Close();
FStream.Close();
}
FStream.Dispose();
}
Saturday, July 21, 2007
Tuesday, July 10, 2007
Add image to ASP.Net 2.0 Menu navigation control
To give more beautiful for intranet systems / sites, we may need icons/images to be displayed along with the menu caption.
To map image with a site map node, add a custom property, say, "menuImage" in the sitemapnode tag as below
<siteMapNode url="~/pages/wemployee.aspx" title=":: Employees" description="" menuImage="~/Images/viewdetail.gif" />
Now, in the code behind, add the code below:-
protected void Menu1_MenuItemDataBound(object sender, MenuEventArgs e)
{
e.Item.ImageUrl = ((SiteMapNode)e.Item.DataItem)["menuImage"];
}
Infact, you can have a harcoded image path as well.
HTH
-::-
To map image with a site map node, add a custom property, say, "menuImage" in the sitemapnode tag as below
<siteMapNode url="~/pages/wemployee.aspx" title=":: Employees" description="" menuImage="~/Images/viewdetail.gif" />
Now, in the code behind, add the code below:-
protected void Menu1_MenuItemDataBound(object sender, MenuEventArgs e)
{
e.Item.ImageUrl = ((SiteMapNode)e.Item.DataItem)["menuImage"];
}
Infact, you can have a harcoded image path as well.
HTH
-::-
Labels:
ASP.Net 2.0,
imageURL,
Menu Control,
SiteMapNode
Tuesday, July 03, 2007
"Error in File < Path..>\ASPNET\LOCALS~1\Temp\Employees {BBE0A87A-CFF9-4682-A6AD-B0E256CF4793}.rpt:" Crystal Report error in ASP.Net 2.0
Did you ever encounter with this error saying
"Error in File C:\DOCUME~1\..\ASPNET\LOCALS~1\Temp\Employees {BBE0A87A-CFF9-4682-A6AD-B0E256CF4793}.rpt: Get page number for group failed" while working with Crystal Report in ASP.Net 2.0 ?
This error will occur when you try a postback in the .net page by a tree node click or so. And the reason behind is while postback, report is not able to find the data.
Resolution
To avoid this error, enable the caching by making the prOperty of CrystalReportSource "Enable Caching = true".
HTH
-::-
"Error in File C:\DOCUME~1\..\ASPNET\LOCALS~1\Temp\Employees {BBE0A87A-CFF9-4682-A6AD-B0E256CF4793}.rpt: Get page number for group failed" while working with Crystal Report in ASP.Net 2.0 ?
This error will occur when you try a postback in the .net page by a tree node click or so. And the reason behind is while postback, report is not able to find the data.
Resolution
To avoid this error, enable the caching by making the prOperty of CrystalReportSource "Enable Caching = true".
HTH
-::-
Subscribe to:
Posts (Atom)