Sunday

ASP.NET/VB.NET Embed pdf into html page



Public Shared Sub EmbToPdf(ByVal objViewcreator As ViewCreatorGeneral, ByVal dtFromDatabase As DataTable, ByVal inColumnArrList As ArrayList, ByVal report_header As String, ByVal originalSort As String)
If Not System.IO.Directory.Exists(System.Web.HttpContext.Current.Server.MapPath("./ViewControlExport/")) Then
System.IO.Directory.CreateDirectory(System.Web.HttpContext.Current.Server.MapPath("./ViewControlExport"))
End If
dim pid as string =Guid.NewGuid.ToString & ".pdf"
Dim filePath As String = System.Web.HttpContext.Current.Server.MapPath("./ViewControlExport/") & pid

Try


Dim inDataSet As DataSet = New DataSet
GeneralHelper.GetDataSetForDiffFormats(dtFromDatabase, inDataSet, inColumnArrList)

'this code convert dataset into pdf document , itext is using
' see post belo for more info
inDataSet.Tables(0).DefaultView.Sort = originalSort
objViewcreator.BindingDataView = inDataSet.Tables(0).DefaultView
objViewcreator.ConvertDataViewToPdf(filePath,report_header,"",new Rectangle(1190,842 )) 'PagesSize.A3 = 1190,842


System.Web.HttpContext.Current.Response.Write("<embed src='" & "./ViewControlExport/" & pid & "#toolbar=1&navpanes=1&scrollbar=1' width='960' height='760'>")

System.Web.HttpContext.Current.Response.End()
Catch ex As Exception
Ubill.Logger.prn(filePath, ex.ToString)
End Try
End Sub


more...

IE7 opening excel files.

may not be working , check out : http://blogs.msdn.com/excel/archive/2006/09/26/771221.aspx



Public Shared Sub ExportToExcel(ByVal objViewcreator As ViewCreatorGeneral, ByVal dtFromDatabase As DataTable, ByVal inColumnArrList As ArrayList, ByVal report_header As String, ByVal originalSort As String)

System.Web.HttpContext.Current.Response.ClearContent()
System.Web.HttpContext.Current.Response.ClearHeaders()
System.Web.HttpContext.Current.Response.Charset = ""
System.Web.HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "inline; filename=report.xls")
System.Web.HttpContext.Current.Response.AddHeader("Pragma", " private")
System.Web.HttpContext.Current.Response.AddHeader("Cache-control", " private, must-revalidate")

'writing tab separated stuff here
Dim tabFile As String = "my tab separted cols crlf separeted rows"
System.Web.HttpContext.Current.Response.BinaryWrite(Encoding.GetBytes(tabFile))

System.Web.HttpContext.Current.Response.End()
End Sub


more...

Monday

read data from SQL sevrer with Ruby/WIN32OLE way



def read_sp(sp_text,sr,db,pwd)
conn = WIN32OLE.new('ADODB.Connection')
conn.Open("driver={SQL Server};Uid=sa;server=#{sr};pwd=#{pwd};database=#{db};")
rset = WIN32OLE.new('ADODB.Recordset')
rset.ActiveConnection = conn
rset.Open(sp_text)
s = ""
while not rset.EOF do
for i in (0..rset.Fields.Count - 1) do
s += rset.Fields.Item(i).Value.to_s.strip
end
rset.MoveNext
end
return s;

end



more...

Using @@Rowcount to Determine the Number of Rows Affected by a SQL


The @@Rowcount function will be set after any statement that changes or returns rows. In the following statement, the RowsReturned column will display the number of rows selected by the previous select statement:

SELECT * FROM AUTHORS
WHERE state = 'CA'
SELECT @@rowcount AS 'RowsReturned'

While this example could obviously be rewritten to use a SELECT COUNT... type of syntax, the @@Rowcount function is useful in that it is also set after any statement that changes rows. As such it is useful in determining how many rows were affected by an INSERT or an UPDATE statement. For example, the following SQL statement changes the city column in the authors table of the pubs database from Salt Lake City to Oakland:

UPDATE authors SET city = 'Oakland' WHERE city = 'Salt Lake City'
SELECT @@rowcount AS 'RowsChanged'

The statement will return the number of rows changed as the RowsChanged column.

more...

imagemagic add text to image

rem different types of text annotations on existing images rem cyan yellow orange gold rem -gravity SouthWest rem draw text and anno...