Along the same lines for this question: I have VS2005 Developer and have purchased Office 2007
Professional and have installed that. I downloaded the Northwind template from Microsoft's Website and created a database with it (I guess that's what I did, anyway) named Northwind 2007.accdb. When I try to do the Try It Out involving the DataGridView Control in Chapter 3 at step 9, I get an error message that the file is not in a recognized format. Is there an add-on or something that will allow VB2005 to link to .accdb files, should I download the 2003 version of Northwind, can I convert the .accdb file to an .mdb? Thank you very much for your assistance. Eric
UPDATE: I went searching on MSDN and found the answer to my question. Here are step-by-step instructions as displayed in the forum post at http://forums.microsoft.com/MSDN/Sho...94617&SiteID=1 Step by step instructions. From the Add Connection dialog:
1) Click the Change button for the Data Source 2) From the Change Data Source dialog select <other> in the Data source list 3) Click the OK button 4) Back to the Add Connection dialog select Microsoft Offfice 12.0 Access Database Engine OLE DB Provider from the OLE DB Provider drop down 5) In the Server or file name text box enter the path to your Access 2007 database file 6) Click the Test Connection button to make certain that you can connect to the database 7) Click on the OK button to finish creating the data source.
accdb.Jet OLEDB:Database Password=MyDbPassword. If you need role based security you need a enterprise level database such as SQL Server. I also want to limit the level of access of the users to the database in my program. Microsoft SQL Server (Express edition is free . Actually. Hope this helps. You can use the connection string below to access your accdb databases through asp.Data Source=C:\database1. if you are using passwords to access your database. I want to connect the program in all PCs to one database in another PC using Microsoft Access. The new office suite version 2007 comes with brand-new file formats.ACE. however once you get over 3 or 4 concurrent users you will start to notice that MS Access doesn't scale well.0.ACE.12. your hosting provider will not be aware of this upgrade or probably you don't want to install Access 2007 on your server. Just install 2007 Office System Driver: Data Connectivity Components.Data Source=C:\database1.
. Of course there is a new connection string for those new access databases. However. One of them is the new Access database format version 2007 with accdb extension. Personally in my old VB6 apps that used MS Access I called the file db.resources rather than db.Below is the text.OLEDB. Provider=Microsoft.net.accdb. In addition. you can include it in your connection string like below.mdb.
Access is capable of handling multiple users.0. This is because a.upto 4GB space) is designed for a large number of concurrent users. You can use folder Permissions if you wish to restrict access to the file.OLEDB.12.Persist Security Info=False. Provider=Microsoft. Access is designed for the professional but not an enterprise.resources file cant be downloaded if it is hosted online (ref DotNetNuke) and also so people dont know which program to open the file in.. you don't need to.
close the Data Link Properties window. g.txt to . Once the Test Connection is successful. Double clcik the udl file and enter these settings and navigate to the shared folder that hosts the shared database:
f. Choose the main PC that will host the database b. Rename the file extension from . a. create a text fileon the desktop. Host the database in a folder that is shared to the other users c.Here is how you can have two computers share the same database. Physically go over to the PC that isn't hosting the database. d. Right click the UDL file on the desktop and choose Open With and open with notepad h. You will see your connection string:
.udl and press enter e.
ByVal e As_ System.Windows.") 'provider to be used when working with access database cn.Load End Sub Private Sub Button1_Click(ByVal sender As System.Persist Security Info=False i.mdb. cn) dr = cmd.Forms.Text = dr(0) TextBox2. Everything after this line is an OLE DB initstring Provider=Microsoft.ExecuteReader While dr.Text = dr(1) TextBox3._ Data Source=C:\emp.Object.12.OLEDB.EventArgs) Handles Button1.Jet.Close() cn.Object.Read() TextBox1.OLEDB.accdb. Set the second pc to use the networked connection string.Data Source=\\PCName\c$\temp\Database1.Click Try cn = New OleDbConnection("Provider=Microsoft.0.Text = dr(2) ' loading data into TextBoxes by column index End While Catch End Try dr.Form Dim cn As OleDbConnection Dim cmd As OleDbCommand Dim dr As OleDbDataReader Private Sub Form1_Load(ByVal sender As System.Open() cmd = New OleDbCommand("select * from table1".EventArgs) Handles MyBase.
Public Class Form1 Inherits System.ACE.[oledb] .4. ByVal e as _ System.0.Close() End Sub End Class
Dim dta As New Tb_AbsensiTableAdapter 5.fill(myDataTable. . Dim objdatatable As DataTable = objDataSet. dttb = dta. Dim dttb As New DataTable 6.clear 6. ByVal e As
.Tables("TableName") 2.1. objAlternatingCellStyle. 3.AutoGenerateColumns = True 5. MyDataAdapter. EndSub
1. Private Sub ucAbsensiTahunan_Load(ByVal sender As System.Load
4. 8. 9. . dim myDataTable as new DataTable 3.DataSource = bindingsource1 9. searchDataGridView.. DataGridView1. myDataTable.table("MyTable") 8.table("MyTable"). dim mycon as new sqlConnection("your conn string") 2. End Sub
1. 9. mycon) 5.AlternatingRowsDefaultCellStyle = objAlternatingCellStyle 12.EventArgs) Handles MyBase. BindingSource1. myconn.DataSource = objDataSet 6."MyTable") 7.DataMember = "TableName" 7.GetData() 'the data table had data from dataset 7. .BackColor = Color.datasource = myDataTable. Dim myDataAdapter as new SqlDataAdapter("your query ".DataSource = dttb 'it doesn't work 8. 3. Public Class ucAbsensiTahunan 2.open() 4. With DataGridView1 4. GataGridView.Object. Dim objAlternatingCellStyle As New DataGridViewCellStyle() 10. ' Declare and set the alternating rows style.WhiteSmoke 11.
4..Fill(ds.mdb path".Integrated Security=True" Dim sql As String = "SELECT * FROM Authors" Dim connection As New SqlConnection(connectionString) Dim dataadapter As New SqlDataAdapter(sql.Click Dim connectionString As String = "Provider=Microsoft.Open() dataadapter.EventArgs) Handles Button1. ByVal e As System. End With
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object." Dim sql As String = "SELECT * FROM Authors" Dim connection As New OleDbConnection(connectionString) Dim dataadapter As New OleDbDataAdapter(sql. "Authors_table") connection.Open() dataadapter.0.OleDb Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Click Dim connectionString As String = "Data Source=.OLEDB.Close() DataGridView1.13.DataSource = ds DataGridView1. connection) Dim ds As New DataSet() connection.DataMember = "Authors_table" End Sub End Class
Imports System.Initial Catalog=pubs.DataSource = ds DataGridView1.Connection Dim rs As ADODB. connection) Dim ds As New DataSet() connection.Recordset Dim tb As DataTable
.Object.Data.EventArgs) Handles Button1. "Authors_table") connection.DataMember = "Authors_table" End Sub End Class
Public Class Form1 Dim con As ADODB.Jet. ByVal e As System.Fill(ds.Close() DataGridView1.Data Source="Your .
Fill(DS) Connection.DataSource = DS.Load con = New ADODB.Jet.adOpenKeyset. ByVal e As System.Persist Security Info=False" con.4.CursorLocation = ADODB.adUseClient con.EventArgs) Handles MyBase. ADODB.Data Source=D:\AMEER & SONS\AMEER&SONS.mdb.DataSource = tb
SQL = "SELECT " & FieldList & " FROM tblMembers WHERE Status='Active'" DS = New DataSet Connection.CursorTypeEnum.adLockOptimistic. Connection) MyAdapter. con.CursorLocationEnum.ConnectionString = "Provider=Microsoft.Object. ADODB.DataSource = rs End Sub End Class
You havn't mapped any data to your DataTable.Open("company_info".OLEDB.Close() grid1.Recordset tb = New DataTable con.Connection rs = New ADODB.. 2) grid.Open() MyAdapter = New OleDbDataAdapter(SQL. which you would use to fill the Grid:
Collapse | Copy Code
tb = New DataTable .LockTypeEnum.0.Open() rs.Private Sub Form1_Load(ByVal sender As System. grid.Tables(0)