Home
Forums
New posts
Search forums
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
C# Community
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
Database
MS Access
How can i filter departmentwise report in datagrid or crystal report?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="sapna21" data-source="post: 117598" data-attributes="member: 27973"><p>I want to filter department wise from following database (MS Access)..</p><p></p><p>S_NO EMP_NAME E_CODE DEPARTMENT COMPANY DIVISION S_DATE E_DATE TOPIC</p><p>1 ANAND 1112 HR abcd ghjk 25-Nov-09 11/25/2009 QA</p><p>2 PANKAJ 3223 QA abcd ghjk 25-Nov-09 11/25/2009 L.F.T</p><p>3 AMITABH 1231 MECHANICAL abcd ghjk 25-Nov-09 11/25/2009 L.F.T</p><p>4 GIRJA SHANKAR 5117 HR abcd ghjk 25-Nov-09 11/25/2009 L.F.T</p><p><span style="color: Blue">Also i am not able to insert, update <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite3" alt=":(" title="Frown :(" loading="lazy" data-shortname=":(" /> data through insert query but i can update through following coding:</span></p><p><span style="color: Blue">Imports CrystalDecisions.CrystalReports.Engine</span></p><p>Public Class Form1</p><p> Dim inc As Integer</p><p> Dim MaxRows As Integer</p><p> Dim con As New OleDb.OleDbConnection</p><p> Dim Command As OleDb.OleDbCommand</p><p> Dim sql As String</p><p> Dim ds As New DataSet</p><p> Dim da As OleDb.OleDbDataAdapter</p><p> Dim datagrid1 As New DataGrid</p><p> Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load</p><p></p><p> con.ConnectionString = "PROVIDER = Microsoft.Jet.OLEDB.4.0;Data source = C:\Users\sapna.sharma\Documents\Training.mdb"</p><p> con.Open()</p><p></p><p> sql = "SELECT * FROM tblContacts"</p><p> da = New OleDb.OleDbDataAdapter(sql, con)</p><p></p><p> da.Fill(ds, "Training")</p><p> datagrid1.DataSource = ds.DefaultViewManager</p><p></p><p> con.Close()</p><p></p><p> MaxRows = ds.Tables("Training").Rows.Count</p><p> inc = -1</p><p> End Sub</p><p></p><p> Private Sub NavigateRecords()</p><p> txtEmp_Name.Text = ds.Tables("Training").Rows(inc).Item(1)</p><p> txtE_code.Text = ds.Tables("Training").Rows(inc).Item(2)</p><p> txtDepartment.Text = ds.Tables("Training").Rows(inc).Item(3)</p><p> txtCompany.Text = ds.Tables("Training").Rows(inc).Item(4)</p><p> txtDivision.Text = ds.Tables("Training").Rows(inc).Item(5)</p><p> txtS_Date.Text = ds.Tables("Training").Rows(inc).Item(6)</p><p> txtE_Date.Text = ds.Tables("Training").Rows(inc).Item(7)</p><p> txtTopic.Text = ds.Tables("Training").Rows(inc).Item(8)</p><p> End Sub</p><p></p><p> Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click</p><p> If inc <> MaxRows - 1 Then</p><p> inc = inc + 1</p><p> NavigateRecords()</p><p> Else</p><p> MsgBox("No More Rows")</p><p> End If</p><p> End Sub</p><p></p><p> Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click</p><p> If inc > 0 Then</p><p> inc = inc - 1</p><p> NavigateRecords()</p><p> ElseIf inc = -1 Then</p><p> MsgBox("No Records Yet")</p><p> ElseIf inc = 0 Then</p><p> MsgBox("First Record")</p><p> End If</p><p> End Sub</p><p></p><p> Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click</p><p> Dim cb As New OleDb.OleDbCommandBuilder(da)</p><p> ds.Tables("Training").Rows(inc).Item(1) = txtEmp_Name.Text</p><p> ds.Tables("Training").Rows(inc).Item(2) = txtE_code.Text</p><p> ds.Tables("Training").Rows(inc).Item(3) = txtDepartment.Text</p><p> ds.Tables("Training").Rows(inc).Item(4) = txtCompany.Text</p><p> ds.Tables("Training").Rows(inc).Item(5) = txtDivision.Text</p><p> ds.Tables("Training").Rows(inc).Item(6) = txtS_Date.Text</p><p> ds.Tables("Training").Rows(inc).Item(7) = txtE_Date.Text</p><p> ds.Tables("Training").Rows(inc).Item(8) = txtTopic.Text</p><p> da.Update(ds, "Training")</p><p></p><p> MsgBox("Data updated")</p><p></p><p> End Sub</p><p></p><p> Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click</p><p> btnCommit.Enabled = True</p><p> btnAdd.Enabled = False</p><p> btnUpdate.Enabled = False</p><p> btnDelete.Enabled = False</p><p></p><p> txtEmp_Name.Clear()</p><p> txtE_code.Clear()</p><p> txtDepartment.Clear()</p><p> txtCompany.Clear()</p><p> txtDivision.Clear()</p><p> txtS_Date.Clear()</p><p> txtE_Date.Clear()</p><p> txtTopic.Clear()</p><p> End Sub</p><p></p><p> Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCommit.Click</p><p> </p><p> If inc <> -1 Then</p><p></p><p> Dim cb As New OleDb.OleDbCommandBuilder(da)</p><p> Dim dsNewRow As DataRow</p><p></p><p> dsNewRow = ds.Tables("Training").NewRow()</p><p></p><p> dsNewRow.Item(1) = txtEmp_Name.Text</p><p> dsNewRow.Item(2) = txtE_code.Text</p><p> dsNewRow.Item(3) = txtDepartment.Text</p><p> dsNewRow.Item(4) = txtCompany.Text</p><p> dsNewRow.Item(5) = txtDivision.Text</p><p> dsNewRow.Item(6) = txtS_Date.Text</p><p> dsNewRow.Item(7) = txtE_Date.Text</p><p> dsNewRow.Item(8) = txtTopic.Text</p><p></p><p> ds.Tables("Training").Rows.Add(dsNewRow)</p><p> MsgBox("New Record added to the Database")</p><p> da.Update(ds, "Training")</p><p></p><p> MsgBox("New Record added to the Database")</p><p></p><p> btnCommit.Enabled = False</p><p> btnAdd.Enabled = True</p><p> btnUpdate.Enabled = True</p><p> btnDelete.Enabled = True</p><p></p><p> End If</p><p> End Sub</p><p></p><p> Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click</p><p> Dim cb As New OleDb.OleDbCommandBuilder(da)</p><p></p><p> ds.Tables("Training").Rows(inc).Delete()</p><p> MaxRows = MaxRows - 1</p><p></p><p> inc = 0</p><p> NavigateRecords()</p><p> da.Update(ds, "Training")</p><p></p><p> If MessageBox.Show("Do you really want to Delete this Record?", _</p><p> "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.No Then</p><p></p><p></p><p> MsgBox("Operation Cancelled")</p><p> Exit Sub</p><p></p><p> End If</p><p> End Sub</p><p></p><p> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click</p><p></p><p></p><p></p><p> Dim cr As New ReportDocument</p><p></p><p> cr.Load("C:\Users\sapna.sharma\Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\CrystalReport2.rpt")</p><p></p><p> CrystalReportViewer1.ReportSource = cr</p><p> CrystalReportViewer1.Refresh()</p><p></p><p> End Sub</p><p></p><p></p><p> Private Sub CrystalReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Load</p><p></p><p> End Sub<span style="color: Red"></span></p><p><span style="color: Red">and also i am not able to update Access database through following code:<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite3" alt=":(" title="Frown :(" loading="lazy" data-shortname=":(" /></span></p><p> Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click</p><p> Dim icount As Integer</p><p></p><p></p><p> con.ConnectionString = "PROVIDER = Microsoft.Jet.OLEDB.4.0;Data source = C:\Users\sapna.sharma\Documents\Training.mdb"</p><p> con.Open()</p><p></p><p> sql = "UPDATE tblContacts SET COMPANY='CAPGEMINI' WHERE EMP_NAME='PANKAJ'"</p><p> da = New OleDb.OleDbDataAdapter(sql, con)</p><p> Command = New OleDb.OleDbCommand(sql, con)</p><p></p><p> da.Fill(ds, "Training")</p><p> icount = Command.ExecuteNonQuery</p><p></p><p> con.Close()</p><p> End Sub</p><p>End Class</p><p></p><p>PLZZZZZZZZZZZZZZZZZZZZZZZZZZZ help meeeeeeeeee<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite3" alt=":(" title="Frown :(" loading="lazy" data-shortname=":(" /></p></blockquote><p></p>
[QUOTE="sapna21, post: 117598, member: 27973"] I want to filter department wise from following database (MS Access).. S_NO EMP_NAME E_CODE DEPARTMENT COMPANY DIVISION S_DATE E_DATE TOPIC 1 ANAND 1112 HR abcd ghjk 25-Nov-09 11/25/2009 QA 2 PANKAJ 3223 QA abcd ghjk 25-Nov-09 11/25/2009 L.F.T 3 AMITABH 1231 MECHANICAL abcd ghjk 25-Nov-09 11/25/2009 L.F.T 4 GIRJA SHANKAR 5117 HR abcd ghjk 25-Nov-09 11/25/2009 L.F.T [COLOR="Blue"]Also i am not able to insert, update :( data through insert query but i can update through following coding: Imports CrystalDecisions.CrystalReports.Engine[/COLOR] Public Class Form1 Dim inc As Integer Dim MaxRows As Integer Dim con As New OleDb.OleDbConnection Dim Command As OleDb.OleDbCommand Dim sql As String Dim ds As New DataSet Dim da As OleDb.OleDbDataAdapter Dim datagrid1 As New DataGrid Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load con.ConnectionString = "PROVIDER = Microsoft.Jet.OLEDB.4.0;Data source = C:\Users\sapna.sharma\Documents\Training.mdb" con.Open() sql = "SELECT * FROM tblContacts" da = New OleDb.OleDbDataAdapter(sql, con) da.Fill(ds, "Training") datagrid1.DataSource = ds.DefaultViewManager con.Close() MaxRows = ds.Tables("Training").Rows.Count inc = -1 End Sub Private Sub NavigateRecords() txtEmp_Name.Text = ds.Tables("Training").Rows(inc).Item(1) txtE_code.Text = ds.Tables("Training").Rows(inc).Item(2) txtDepartment.Text = ds.Tables("Training").Rows(inc).Item(3) txtCompany.Text = ds.Tables("Training").Rows(inc).Item(4) txtDivision.Text = ds.Tables("Training").Rows(inc).Item(5) txtS_Date.Text = ds.Tables("Training").Rows(inc).Item(6) txtE_Date.Text = ds.Tables("Training").Rows(inc).Item(7) txtTopic.Text = ds.Tables("Training").Rows(inc).Item(8) End Sub Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click If inc <> MaxRows - 1 Then inc = inc + 1 NavigateRecords() Else MsgBox("No More Rows") End If End Sub Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click If inc > 0 Then inc = inc - 1 NavigateRecords() ElseIf inc = -1 Then MsgBox("No Records Yet") ElseIf inc = 0 Then MsgBox("First Record") End If End Sub Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click Dim cb As New OleDb.OleDbCommandBuilder(da) ds.Tables("Training").Rows(inc).Item(1) = txtEmp_Name.Text ds.Tables("Training").Rows(inc).Item(2) = txtE_code.Text ds.Tables("Training").Rows(inc).Item(3) = txtDepartment.Text ds.Tables("Training").Rows(inc).Item(4) = txtCompany.Text ds.Tables("Training").Rows(inc).Item(5) = txtDivision.Text ds.Tables("Training").Rows(inc).Item(6) = txtS_Date.Text ds.Tables("Training").Rows(inc).Item(7) = txtE_Date.Text ds.Tables("Training").Rows(inc).Item(8) = txtTopic.Text da.Update(ds, "Training") MsgBox("Data updated") End Sub Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click btnCommit.Enabled = True btnAdd.Enabled = False btnUpdate.Enabled = False btnDelete.Enabled = False txtEmp_Name.Clear() txtE_code.Clear() txtDepartment.Clear() txtCompany.Clear() txtDivision.Clear() txtS_Date.Clear() txtE_Date.Clear() txtTopic.Clear() End Sub Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCommit.Click If inc <> -1 Then Dim cb As New OleDb.OleDbCommandBuilder(da) Dim dsNewRow As DataRow dsNewRow = ds.Tables("Training").NewRow() dsNewRow.Item(1) = txtEmp_Name.Text dsNewRow.Item(2) = txtE_code.Text dsNewRow.Item(3) = txtDepartment.Text dsNewRow.Item(4) = txtCompany.Text dsNewRow.Item(5) = txtDivision.Text dsNewRow.Item(6) = txtS_Date.Text dsNewRow.Item(7) = txtE_Date.Text dsNewRow.Item(8) = txtTopic.Text ds.Tables("Training").Rows.Add(dsNewRow) MsgBox("New Record added to the Database") da.Update(ds, "Training") MsgBox("New Record added to the Database") btnCommit.Enabled = False btnAdd.Enabled = True btnUpdate.Enabled = True btnDelete.Enabled = True End If End Sub Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click Dim cb As New OleDb.OleDbCommandBuilder(da) ds.Tables("Training").Rows(inc).Delete() MaxRows = MaxRows - 1 inc = 0 NavigateRecords() da.Update(ds, "Training") If MessageBox.Show("Do you really want to Delete this Record?", _ "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.No Then MsgBox("Operation Cancelled") Exit Sub End If End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim cr As New ReportDocument cr.Load("C:\Users\sapna.sharma\Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\CrystalReport2.rpt") CrystalReportViewer1.ReportSource = cr CrystalReportViewer1.Refresh() End Sub Private Sub CrystalReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Load End Sub[COLOR="Red"] and also i am not able to update Access database through following code::([/COLOR] Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click Dim icount As Integer con.ConnectionString = "PROVIDER = Microsoft.Jet.OLEDB.4.0;Data source = C:\Users\sapna.sharma\Documents\Training.mdb" con.Open() sql = "UPDATE tblContacts SET COMPANY='CAPGEMINI' WHERE EMP_NAME='PANKAJ'" da = New OleDb.OleDbDataAdapter(sql, con) Command = New OleDb.OleDbCommand(sql, con) da.Fill(ds, "Training") icount = Command.ExecuteNonQuery con.Close() End Sub End Class PLZZZZZZZZZZZZZZZZZZZZZZZZZZZ help meeeeeeeeee:( [/QUOTE]
Insert quotes…
Verification
Post reply
Home
Forums
Database
MS Access
How can i filter departmentwise report in datagrid or crystal report?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top
Bottom