如何使用Access数据库在Vbnet中生成报告 [英] How to generate a report in Vbnet with Access database

查看:92
本文介绍了如何使用Access数据库在Vbnet中生成报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好开发人员

我想得到您的任何帮助,我想知道如何为我的系统制作报告,我在vbnet 2010(visual studio 2010express)中使用access 2007数据库进行开发。

如果我从访问数据库或vbnet这样做,我会知道它是否公平。





第二个问题是关于如何将用户详细信息的表连接到员工表(logintable)和角色表,现在我使用员工表连接到登录界面,它有用户名,密码,RoleId和角色id具有Roleid和Role。

在用户详细信息表中我有姓,姓,姓,RoleId和地址,但我不知道如何连接它们,以便通过用户详细信息表可以保存员工表的信息将使用,基本上是为了帮助用户注册系统使用。



请帮帮我。



谢谢你

Hello developers guys
I would like any help from you, I want to know how i can make reports for my system i m developing in vbnet 2010 (visual studio 2010express) with access 2007 database.
I would to know if it is fair if I do it from access database or from vbnet.


The second question is about how I can connect the table that will hold user details to staff table(logintable) and role table, now I m using staff table wich is connect to login interface, it has username,password, RoleId, and role id has Roleid and Role.
in user details table i m having firstname,surname,lastname, RoleId and address,But I don't know how I can connect them, so that through user details table can hold the information that the staff table will be using, basically to help user registering with the system for use.

Please help me out.

Thank u

推荐答案

报告在访问本身最简单,因为它提供模板,但这是一个简单的例子,在VB .Net 2010中使用OLEDB来打开和读取将两个表连接在一起的访问数据库。



示例是一个法语客户端的数据库,所以名称是法语,我刚刚创建了一个带有tetbox的表单,滚动条和多行设置为true但你可以随意处理数据。
reporting is easiest in access itself as it provides templates but here is a simple example using OLEDB in VB .Net 2010 to open and read an access database joining two tables together.

the example is a database for a french client so the names are in french, i just created a form with a tetbox on it with scroll bars and multiline set to true but you can handle the data as you like.





您可以按名称或列索引访问字段(基于零) )。



将Imports System.Data.OLEDB放在班级顶部



使用conn作为新的OleDbConnection (Provider = Microsoft.Jet.OLEDB.4.0; Data Source = D:\ My Documents \DOWNLOAD \ GESTION.mdb)



使用cmd As新的OleDbCommand(SELECT Produits。*,Fournisseurs.Ville FROM Produits LEFT JOIN Fournisseurs ON Fournisseurs.NomFournisseur = produits.Fournisseur,conn)



Dim rd As OleDbDataReader



尝试

conn.Open()



rd = cmd.ExecuteReader



Do while rd.Read

TextBox1.Text + = rd(1)+:+ rd(Ville)+ vbCrLf



Application.DoEvents()

循环



rd.Close ()



Catch ex As Exception

MsgBox(无法访问数据库。+ vbCrLf + vbCrLf + ex.Message)

结束尝试



conn.Close()

结束使用

结束使用



you can access fields either by name or by column index (zero based).

put Imports System.Data.OLEDB at the top of the class

Using conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\My Documents\DOWNLOAD\GESTION.mdb")

Using cmd As New OleDbCommand("SELECT Produits.*,Fournisseurs.Ville FROM Produits LEFT JOIN Fournisseurs ON Fournisseurs.NomFournisseur=produits.Fournisseur", conn)

Dim rd As OleDbDataReader

Try
conn.Open()

rd = cmd.ExecuteReader

Do While rd.Read
TextBox1.Text += rd(1) + " : " + rd("Ville") + vbCrLf

Application.DoEvents()
Loop

rd.Close()

Catch ex As Exception
MsgBox("Cannot Access DB." + vbCrLf + vbCrLf + ex.Message)
End Try

conn.Close()
End Using
End Using


这篇关于如何使用Access数据库在Vbnet中生成报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆