I have added form1 and on it 2 text boxes.
text box1 to accept fromdate and textbox2 to accept todate.
After this,I added Crystal report from Add new Item.
Then in Crystal report I added table and its columns.
After that I wrote code behind form1.
The code is not correct but I have tried it.
Its as follows:
Imports System.Data
Imports System.Data.SqlClient
Imports System.Windows.Forms
Public Class REPORT
Private dataadapter As SqlDataAdapter
Dim str_com As String = "Data Source=COMPAQ\SQLEXPRESS;Initial Catalog=LibTry;Integrated Security=True"
Dim objcon As SqlConnection
Dim objcmd As SqlCommand
Dim frmDate As DateTime
Dim toDate As DateTime
Private Sub call1(ByVal frmDate As Date, ByVal toDate As Date)
Dim objcon As New SqlConnection("Data Source=COMPAQ\SQLEXPRESS;Initial Catalog=LibTry;Integrated
Security=True")
objcon.Open()
Dim str_con As String = "select * from IssueMBA where dtaccess between '" + frmDate + "' and ' " + toDate + "'"
objcmd = New SqlCommand(str_con, objcon)
Dim ds As New DataSet
Dim dataadapter As New SqlDataAdapter(objcmd)
dataadapter.Fill(ds)
objcon.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
frmDate = Date.Parse(TextBox1.Text)
toDate = Date.Parse(TextBox2.Text)
call1(frmDate, toDate)
CrystalReport1()
Me.Close()
End Sub
Private Sub REPORT_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
objcon = New SqlConnection(str_com)
End Sub
End Class
You might have come across this report before also but I am trying to do it in this way and not able to do.