473,466 Members | 1,646 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

VB6 Reading data from Mdb to MS Office web component (excel)

104 New Member
Hi all, I have a mdb with data in it. In my VB project I have Excel embedded on a form. The following code I am using to get data from the db and then "paste"it into the excel sheet. I get a read access error. The same database is feeding a Datagrid and exporting to excel (outside vb) with no hassle. Can someone tell me if they can spot a problem. Is there maybe a better way to do this other than this code. Thanks


Error Message is : Records cannot be read, no permission on 'MSysACEs'

VB Code:

Private Sub Command14_Click()
Dim cn As New ADODB.Connection
Dim oSchema As ADODB.Recordset
Dim rs As New ADODB.Recordset
Dim intFldCnt As Integer
Dim i As Integer
Dim j As Integer
Dim sngColWid As Single


Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + App.Path & "\data\adodb1s.mdb"

strDBName = App.Path & "\" & "\data\adodb1s.mdb"

cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBName & ";Persist Security Info=false"
cn.Open (strDBName)
Set oSchema = cn.OpenSchema(adSchemaTables)

Do Until oSchema.EOF

rs.Open "select * from [" & oSchema!table_name & "]", cn
intFldCnt = rs.Fields.Count - 1

For i = 1 To intFldCnt
Report1.Spreadsheet1.Cells(100, i) = rs.Fields(i).Name
If TextWidth(rs.Fields(i).Name) > sngColWid Then
sngColWid = TextWidth(rs.Fields(i).Name)
End If
Next i

j = 2
Do Until rs.EOF
For i = 1 To intFldCnt
Report1.Spreadsheet1.Cells(j, i) = rs.Fields(i).Value
Next i
j = j + 1
rs.MoveNext
Loop
rs.Close
Debug.Print oSchema!table_name

oSchema.MoveNext
Loop
Wait.Hide

Screen.MousePointer = vbNormal
Exit Sub
End Sub
Sep 3 '08 #1
1 3963
smartchap
236 New Member
May be u correct the following line:

strDBName = App.Path & "\" & "\data\adodb1s.mdb"

with

strDBName = App.Path & "\data\adodb1s.mdb"

meanwhile I will try to check ur code.
Sep 5 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: jinu | last post by:
hello, I need to run a vb.net application in different OSs like windows 2003, windows 2000, windows 98 etc.... where only windows 2003 have built-in .net framework and to be installed in...
0
by: Alex Shirley | last post by:
Hi I'm still banging my head on how to import an Excel XML spreadsheet into a dataset. The code will work for standard XML files, but not XML files made with Excel (I get 'Specified cast is not...
1
by: ns2k | last post by:
I develop an Addins Project for Excel in Visual Studio.NET that I need it to work for any machine in any Microsoft Office XP. I use the dependecy (reference)...
5
by: prasanta | last post by:
Hello, I have a xml file. when i am trying to load through XPathDocument and try to get XPathNodeIterator its not working . my xml is loking like <?xml version="1.0" ?> <?mso-application...
1
by: BK | last post by:
I have a .NET Solution (currently in 2003, FW 1.1) that uses Office automation for a few things (generates a Word document, dumps datagrids to Excel, etc.). One of my programmers works on the...
0
by: thought.contagion | last post by:
I need to determine if Excel 2007 is installed. For Office 2003, we had the component ID for Excel 2003 and could use the msi.dll to enumerate and that would tell us if it was installed: iRet...
3
by: Bharathi | last post by:
Hi, I got strucked with reading date value from excel file using C#.NET. For Jan-2000 the value I am getting is 36526.0. For all other dates also I am getting some double value like this. ...
4
by: amphibian1 | last post by:
I'm trying to write a C# application that iterates through a collection of Microsoft Office documents and standardizes the meta data of those documents (e.g. the author and company name). ...
2
by: i.arda.tezcan | last post by:
Hello, I'm trying to make a web page that will read the xls file and make a table out of it on the web page. I want to change the excel file from time to time and I want the changes to be...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.