Help ---Generate Report using richtext box

sunnyjulka

Member
Joined
Sep 12, 2005
Messages
17
Programming Experience
1-3
Hi
I am very new to reports...I want to have a sql query result to show as a report. I was trying to work with richtext and made a Word file with extention .rtf and then I was trying to replace the file with the sql query result. The following is the code. Any ideas are welcome

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strFileName As String = "Q:\Capstone CSC\Register\Word Templates\ShiftReport.rtf"
Dim fs As New FileStream(strFileName, FileMode.Open)
Dim dr As New StreamReader(fs)
Dim strText As String = dr.ReadToEnd()
dr.Close()
fs.Close()
'rtbShiftReport.Rtf = strText
Dim strConn As String = "Persist Security Info=True;Initial Catalog=c450bzsingh;Data Source=CSCSQL;User Id=user;Password=user"
Dim sqlConn As New SqlConnection(strConn)
Dim sqlComm As New SqlCommand("spRPTShiftEmpInfo", sqlConn)
Dim sqlDA As New SqlDataAdapter(sqlComm)
Dim dt As New DataTable
sqlConn.Open()
sqlComm.CommandType = CommandType.StoredProcedure
sqlComm.Parameters.Add("@Emp_ID", SqlDbType.Int).Value = 1
sqlDA.Fill(dt)
sqlConn.Close()
strText.Replace("@@Employee", empName)
strText.Replace("@@PunchIn", dt.Rows(0).Item("PunchInTime"))
strText.Replace("@@PunchOut", dt.Rows(0).Item("PunchOutTime"))
strText.Replace("@@Register", dt.Rows(0).Item("RegisterNo"))
'rtbShiftReport.Rtf = strText

End Sub

For some reason this code is not replacing @@Employee, @@PunchIn, .....
with the values from the queries.

Thanks for ur time.
Any other ideas on reports are also welcome.



 
Back
Top