Showing posts with label adox. Show all posts
Showing posts with label adox. Show all posts

Tuesday, March 6, 2012

ADOX problem...?

I need to rename tables in code VB2005 (access database). On the

forum I found post about ADOX and this code to rename the tables:

Private Sub RenameTables(ByVal sTextToRemove As String)

Dim i As Integer

Dim dbRename As Database

Dim Connect As New PrivDBEngine


dbRename = Connect.OpenDatabase(tbDBPath.Text)

dbRename.CreateTableDef()


For i = 0 To dbRename.TableDefs.Count - 1

If dbRename.TableDefs(i).Name.Length >= sTextToRemove.Length - 1 Then

If dbRename.TableDefs(i).Name.Substring(0, 9) = sTextToRemove Then

dbRename.TableDefs(i).Name = dbRename.TableDefs(i).Name.Substring(9)

End If

End If

Next i


dbRename.Close()

dbRename = Nothing


MessageBox.Show("Tables in " + tbDBPath.Text + " have been renamed.

Rename Access Tables", MessageBoxButtons.OK, MessageBoxIcon.Information)


End Sub

But it doesn't work because i get an error on Dim dbRename As Database Dim Connect As New PrivDBEngine

What I need to do for this to work?

Thank you!


The code is for DAO so the first thing you need to do is add the DAO 3.6 COM library reference to your application (Project...Add Reference).

Then, I would declare those objects and fully qualify the types using the library name:

Dim dbRename As DAO.Database
Dim Connect As DAO.PrivDBEngine

|||

Hi,

Please do the following process to add the required references,

1. Right click on your project in Solution explorer and select Add references...
2. Select COM tab and search for following two libraries and add it,
- Microsoft ADO Ext. 2.8 for DLL and Security
- Microsoft DAO 3.6 Object Library
To see those dlls in References section,
Select Project -> Show all files
So under the References the following two dlls will be shown:
1. ADOX
2. DAO

The code does the following things in MS Access
1. Create database
2. Create a table
3. Rename a table

[The following code creates TestDB.mdb in C:\ and create a table named MyTable. Then it renamed as "MyNewNameTable"]

Imports ADOX

Imports DAO

Public Class Form1

Dim catalog As Catalog = New ADOX.Catalog()

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

CreateDatabaseAndTable("TestDB.mdb", "MyTable")

RenameTables("MyTable", "MyNewNameTable")

End Sub

Private Sub CreateDatabaseAndTable(ByVal databasename As String, ByVal tablename As String)

catalog.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & _

"Data Source=C:\" + databasename + ";" & _

"Jet OLEDB:Engine Type=5")

Console.WriteLine("Database Created Successfully")

Dim firsttable As Table = New Table()

firsttable.Name = tablename

firsttable.Columns.Append("CustID", ADOX.DataTypeEnum.adInteger)

firsttable.Columns.Append("CustName", ADOX.DataTypeEnum.adVarWChar, 30)

firsttable.Keys.Append("PK_CustID", 1, "CustID")

catalog.Tables.Append(firsttable)

firsttable = Nothing

catalog = Nothing

End Sub

Private Sub RenameTables(ByVal sOldName As String, ByVal sNewName As String)

Dim i As Integer

Dim databasepath = "C:\TestDB.mdb"

Dim dbRename As Database

Dim Connect As New PrivDBEngine

dbRename = Connect.OpenDatabase(databasepath)

dbRename.CreateTableDef()

For i = 0 To dbRename.TableDefs.Count - 1

Try

If dbRename.TableDefs(i).Name = sOldName Then

dbRename.TableDefs(i).Name = sNewName

End If

Catch ex As Exception

Console.WriteLine(ex.Message)

End Try

Next i

dbRename.Close()

dbRename = Nothing

MessageBox.Show("Tables in " & databasepath & " have been renamed. Rename Access Tables")

End Sub

End Class

For further information, please refer,
http://www.4guysfromrolla.com/webtech/013101-1.shtml
http://www.4guysfromrolla.com/webtech/tips/t030802-1.shtml
http://www.microsoft.com/technet/prodtechnol/sql/70/proddocs/msjet/jetch02.mspx?mfr=true
http://www.codeguru.com/vb/gen/vb_database/microsoftaccess/article.php/c5149/

HTH,

Sunday, February 19, 2012

ADO Interop Using MDAC 2.8 On Vista

I am trying to load a project under VS2005 under Windows Vista that references an ADOX wrapper that is looking for version 2.8.0.0. The reference fails because the library is not registered.

I thought maybe installing MDAC 2.8 would solve my problems, but when I run the installer for that, it briefly puts up a dialog that it is extracting files, then it disappears.

Any ideas?

--Bruce

Hi Bruce,

Did you ever get this problem solved? I'm getting a similar problem on a Windows 2000 machine. Whenever we try to do ADOX Interop we get a "Library not registered" exception. We can't replicate this behaviour as it's on a client machine using Terminal Services.

Regards,

Brent

|||

Hi,

Just a note to all, registering the msadox.dll could solve the "Library not registered" problem when trying to use ADOX Interop.

regsvr32 "C:\Program Files\Common Files\System\ado\msadox.dll"

Hope this helps someone.

- Brent

|||

I have found that registering msadox does not help in this case because the msadox version that lives in vista is 6.0, whereas the latest version I have been able to find is 2.8. Does anyone know where the 6.0 version comes from?

Jeff

|||

I have found that MDAC has been replaced by WDAC as this article describes: http://msdn2.microsoft.com/en-us/library/ms692897.aspx That is where the 6.0 version comes from. Now I just need to know how to get 2.8 on the system.

|||

Take a look at this link that talks about Redistributing MDAC 28 : http://msdn2.microsoft.com/en-us/library/ms693148.aspx

Also can you add "Microsoft ActiveX Data Objects 2.8 Library", "Microsoft ADO Ext 6.0 for DDL and Security" to your project references and see if it helps?

msado28.tlb should be there in \Program Files\Common Files\System\ado location

Hope this helps

|||

Okay, so have any of the above lead to a solution? My problem is that I have this new development laptop with Vista. But my code needs to run on Server 2000/2003 and XP. So how do I get my project to build with a reference to ADOX 2.8 on Vista? Or, if I replace my ADOX 2.8 reference with one to ADOX 6.0, will I be able to install my project on an XP machine?

I'm posting this because I'm not sure if any of the above have actually fixed the problem. Please correct me if I'm wrong.

Thanks.

Kenneth.

|||Could you try having your msadox.dll of the lowest version you want create .net metadata dll like:

tlbimp msadox.dll /out:ADOX28.dll

Then put this ADOX28.dll file on your development machine and add reference to it.|||

Okay, so that seems to get me to be able to build if I do this:

using ADOX = ADOX28;

But I don't think that'll help me deploy to XP right?

So I did this on an XP development machine with ADOX installed then moved the resultant output to my Vista development machine:

tlbimp ADOX.dll /namespace:ADOX /asmversion:2.8 /out:ADOX28.dll

So now I can simply do:

using ADOX;

Thanks.

Kenneth.

ADO Interop Using MDAC 2.8 On Vista

I am trying to load a project under VS2005 under Windows Vista that references an ADOX wrapper that is looking for version 2.8.0.0. The reference fails because the library is not registered.

I thought maybe installing MDAC 2.8 would solve my problems, but when I run the installer for that, it briefly puts up a dialog that it is extracting files, then it disappears.

Any ideas?

--Bruce

Hi Bruce,

Did you ever get this problem solved? I'm getting a similar problem on a Windows 2000 machine. Whenever we try to do ADOX Interop we get a "Library not registered" exception. We can't replicate this behaviour as it's on a client machine using Terminal Services.

Regards,

Brent

|||

Hi,

Just a note to all, registering the msadox.dll could solve the "Library not registered" problem when trying to use ADOX Interop.

regsvr32 "C:\Program Files\Common Files\System\ado\msadox.dll"

Hope this helps someone.

- Brent

|||

I have found that registering msadox does not help in this case because the msadox version that lives in vista is 6.0, whereas the latest version I have been able to find is 2.8. Does anyone know where the 6.0 version comes from?

Jeff

|||

I have found that MDAC has been replaced by WDAC as this article describes: http://msdn2.microsoft.com/en-us/library/ms692897.aspx That is where the 6.0 version comes from. Now I just need to know how to get 2.8 on the system.

|||

Take a look at this link that talks about Redistributing MDAC 28 : http://msdn2.microsoft.com/en-us/library/ms693148.aspx

Also can you add "Microsoft ActiveX Data Objects 2.8 Library", "Microsoft ADO Ext 6.0 for DDL and Security" to your project references and see if it helps?

msado28.tlb should be there in \Program Files\Common Files\System\ado location

Hope this helps

|||

Okay, so have any of the above lead to a solution? My problem is that I have this new development laptop with Vista. But my code needs to run on Server 2000/2003 and XP. So how do I get my project to build with a reference to ADOX 2.8 on Vista? Or, if I replace my ADOX 2.8 reference with one to ADOX 6.0, will I be able to install my project on an XP machine?

I'm posting this because I'm not sure if any of the above have actually fixed the problem. Please correct me if I'm wrong.

Thanks.

Kenneth.

|||Could you try having your msadox.dll of the lowest version you want create .net metadata dll like:

tlbimp msadox.dll /out:ADOX28.dll

Then put this ADOX28.dll file on your development machine and add reference to it.|||

Okay, so that seems to get me to be able to build if I do this:

using ADOX = ADOX28;

But I don't think that'll help me deploy to XP right?

So I did this on an XP development machine with ADOX installed then moved the resultant output to my Vista development machine:

tlbimp ADOX.dll /namespace:ADOX /asmversion:2.8 /out:ADOX28.dll

So now I can simply do:

using ADOX;

Thanks.

Kenneth.

ADO Interop Using MDAC 2.8 On Vista

I am trying to load a project under VS2005 under Windows Vista that references an ADOX wrapper that is looking for version 2.8.0.0. The reference fails because the library is not registered.

I thought maybe installing MDAC 2.8 would solve my problems, but when I run the installer for that, it briefly puts up a dialog that it is extracting files, then it disappears.

Any ideas?

--Bruce

Hi Bruce,

Did you ever get this problem solved? I'm getting a similar problem on a Windows 2000 machine. Whenever we try to do ADOX Interop we get a "Library not registered" exception. We can't replicate this behaviour as it's on a client machine using Terminal Services.

Regards,

Brent

|||

Hi,

Just a note to all, registering the msadox.dll could solve the "Library not registered" problem when trying to use ADOX Interop.

regsvr32 "C:\Program Files\Common Files\System\ado\msadox.dll"

Hope this helps someone.

- Brent

|||

I have found that registering msadox does not help in this case because the msadox version that lives in vista is 6.0, whereas the latest version I have been able to find is 2.8. Does anyone know where the 6.0 version comes from?

Jeff

|||

I have found that MDAC has been replaced by WDAC as this article describes: http://msdn2.microsoft.com/en-us/library/ms692897.aspx That is where the 6.0 version comes from. Now I just need to know how to get 2.8 on the system.

|||

Take a look at this link that talks about Redistributing MDAC 28 : http://msdn2.microsoft.com/en-us/library/ms693148.aspx

Also can you add "Microsoft ActiveX Data Objects 2.8 Library", "Microsoft ADO Ext 6.0 for DDL and Security" to your project references and see if it helps?

msado28.tlb should be there in \Program Files\Common Files\System\ado location

Hope this helps

|||

Okay, so have any of the above lead to a solution? My problem is that I have this new development laptop with Vista. But my code needs to run on Server 2000/2003 and XP. So how do I get my project to build with a reference to ADOX 2.8 on Vista? Or, if I replace my ADOX 2.8 reference with one to ADOX 6.0, will I be able to install my project on an XP machine?

I'm posting this because I'm not sure if any of the above have actually fixed the problem. Please correct me if I'm wrong.

Thanks.

Kenneth.

|||Could you try having your msadox.dll of the lowest version you want create .net metadata dll like:

tlbimp msadox.dll /out:ADOX28.dll

Then put this ADOX28.dll file on your development machine and add reference to it.|||

Okay, so that seems to get me to be able to build if I do this:

using ADOX = ADOX28;

But I don't think that'll help me deploy to XP right?

So I did this on an XP development machine with ADOX installed then moved the resultant output to my Vista development machine:

tlbimp ADOX.dll /namespace:ADOX /asmversion:2.8 /out:ADOX28.dll

So now I can simply do:

using ADOX;

Thanks.

Kenneth.

ADO Interop Using MDAC 2.8 On Vista

I am trying to load a project under VS2005 under Windows Vista that references an ADOX wrapper that is looking for version 2.8.0.0. The reference fails because the library is not registered.

I thought maybe installing MDAC 2.8 would solve my problems, but when I run the installer for that, it briefly puts up a dialog that it is extracting files, then it disappears.

Any ideas?

--Bruce

Hi Bruce,

Did you ever get this problem solved? I'm getting a similar problem on a Windows 2000 machine. Whenever we try to do ADOX Interop we get a "Library not registered" exception. We can't replicate this behaviour as it's on a client machine using Terminal Services.

Regards,

Brent

|||

Hi,

Just a note to all, registering the msadox.dll could solve the "Library not registered" problem when trying to use ADOX Interop.

regsvr32 "C:\Program Files\Common Files\System\ado\msadox.dll"

Hope this helps someone.

- Brent

|||

I have found that registering msadox does not help in this case because the msadox version that lives in vista is 6.0, whereas the latest version I have been able to find is 2.8. Does anyone know where the 6.0 version comes from?

Jeff

|||

I have found that MDAC has been replaced by WDAC as this article describes: http://msdn2.microsoft.com/en-us/library/ms692897.aspx That is where the 6.0 version comes from. Now I just need to know how to get 2.8 on the system.

|||

Take a look at this link that talks about Redistributing MDAC 28 : http://msdn2.microsoft.com/en-us/library/ms693148.aspx

Also can you add "Microsoft ActiveX Data Objects 2.8 Library", "Microsoft ADO Ext 6.0 for DDL and Security" to your project references and see if it helps?

msado28.tlb should be there in \Program Files\Common Files\System\ado location

Hope this helps

|||

Okay, so have any of the above lead to a solution? My problem is that I have this new development laptop with Vista. But my code needs to run on Server 2000/2003 and XP. So how do I get my project to build with a reference to ADOX 2.8 on Vista? Or, if I replace my ADOX 2.8 reference with one to ADOX 6.0, will I be able to install my project on an XP machine?

I'm posting this because I'm not sure if any of the above have actually fixed the problem. Please correct me if I'm wrong.

Thanks.

Kenneth.

|||Could you try having your msadox.dll of the lowest version you want create .net metadata dll like:

tlbimp msadox.dll /out:ADOX28.dll

Then put this ADOX28.dll file on your development machine and add reference to it.|||

Okay, so that seems to get me to be able to build if I do this:

using ADOX = ADOX28;

But I don't think that'll help me deploy to XP right?

So I did this on an XP development machine with ADOX installed then moved the resultant output to my Vista development machine:

tlbimp ADOX.dll /namespace:ADOX /asmversion:2.8 /out:ADOX28.dll

So now I can simply do:

using ADOX;

Thanks.

Kenneth.