473,625 Members | 3,306 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Run-time error '3251' - While trying to link a table in VB6

richardhodge
2 New Member
I am a VB6 database programmer and have run into a small problem. The company I work for primarily uses Microsoft Access 2000 for the database that is the back end for our software. Well the functionality that I am currently working on creates a table in one database and then links it into the primary database that is used by the program to store and retrieve data from.

Here's the problem. I can create the table fine but when I go to link the table I get a run time error as follows:
Run-time error '3251': Operation is not supported for this type of object.

I have looked all over the internet to find a solution to this problem but can't seem to figure it out or figure out a better way of accomplishing what I am trying to do. I'll go ahead and post my code and hopefully someone has an idea on what to fix.

VB6 Code:::::::

Expand|Select|Wrap|Line Numbers
  1. Private Function createlink()
  2.     Dim dbstemp As DAO.Database
  3.     Dim tdf As DAO.TableDef
  4.     Set dbstemp = DBEngine.OpenDatabase(LinkDB.Name)
  5.     On Error Resume Next
  6.     Set tdf = dbstemp.TableDefs(Name)
  7.     If Err.Number <> 0 Then
  8.         On Error GoTo 0
  9.         'the link does not exist yet so create it
  10.         Set tdf = dbstemp.CreateTableDef("ZZZZtesting")
  11.         'Create tabledef defining the link to the table we want
  12.         tdf.Connect = ";DATABASE=" & dpc.DBPath & "\cinfoEIRS.mdb"
  13.         'name of the table in the source DB
  14.         tdf.SourceTableName = "ZZZZtesting"
  15.         'Add the tabledef to the link database
  16.         'On Error Resume Next
  17.         dbstemp.TableDefs.Append (tdf)
  18.         dbstemp.TableDefs.Refresh
  19.     End If
  20.     On Error GoTo 0
  21.  
  22.     Set dbstemp = Nothing
  23.     Set tdf = Nothing
  24. End Function
DBengine is a global variable that points to our workspace.
LinkDB is a global variable that points to the main database that has all of the links in it.
dpc.DBPath is a global class that has the path for all databases

things that I have tried that have not worked:
- put all attributes for the tabledef into one createTableDef command
- creating a new table def and then try appending
- create a new workspace
- Ignoring the error

Everything except ignoring the error breaks at the same point, at the command:
dbstemp.TableDe fs.Append (tdf)
And it is always the same error 3251.

Well if anyone has any insight into this I would appreciate it.
Mar 6 '07 #1
10 6753
willakawill
1,646 Top Contributor
Although I never use dao or tabledef there is something about this code that does not look right to me. I think you would normally create a tabledef object and then append it to the database. After that you can set its properties (see here). I don't think you can set the tabledef to an existing object and then append it again.

Also your function does not have a return type or value.
Mar 6 '07 #2
Killer42
8,435 Recognized Expert Expert
Got it!

Change
dbstemp.TableDe fs.Append (tdf)
to
dbstemp.TableDe fs.Append tdf
Mar 7 '07 #3
vijaydiwakar
579 Contributor
I am a VB6 database programmer and have run into a small problem. The company I work for primarily uses Microsoft Access 2000 for the database that is the back end for our software. Well the functionality that I am currently working on creates a table in one database and then links it into the primary database that is used by the program to store and retrieve data from.

Here's the problem. I can create the table fine but when I go to link the table I get a run time error as follows:
Run-time error '3251': Operation is not supported for this type of object.

I have looked all over the internet to find a solution to this problem but can't seem to figure it out or figure out a better way of accomplishing what I am trying to do. I'll go ahead and post my code and hopefully someone has an idea on what to fix.

VB6 Code:::::::

Expand|Select|Wrap|Line Numbers
  1. Private Function createlink()
  2.     Dim dbstemp As DAO.Database
  3.     Dim tdf As DAO.TableDef
  4.     Set dbstemp = DBEngine.OpenDatabase(LinkDB.Name)
  5.     On Error Resume Next
  6.     Set tdf = dbstemp.TableDefs(Name)
  7.     If Err.Number <> 0 Then
  8.         On Error GoTo 0
  9.         'the link does not exist yet so create it
  10.         Set tdf = dbstemp.CreateTableDef("ZZZZtesting")
  11.         'Create tabledef defining the link to the table we want
  12.         tdf.Connect = ";DATABASE=" & dpc.DBPath & "\cinfoEIRS.mdb"
  13.         'name of the table in the source DB
  14.         tdf.SourceTableName = "ZZZZtesting"
  15.         'Add the tabledef to the link database
  16.         'On Error Resume Next
  17.         dbstemp.TableDefs.Append (tdf)
  18.         dbstemp.TableDefs.Refresh
  19.     End If
  20.     On Error GoTo 0
  21.  
  22.     Set dbstemp = Nothing
  23.     Set tdf = Nothing
  24. End Function
DBengine is a global variable that points to our workspace.
LinkDB is a global variable that points to the main database that has all of the links in it.
dpc.DBPath is a global class that has the path for all databases

things that I have tried that have not worked:
- put all attributes for the tabledef into one createTableDef command
- creating a new table def and then try appending
- create a new workspace
- Ignoring the error

Everything except ignoring the error breaks at the same point, at the command:
dbstemp.TableDe fs.Append (tdf)
And it is always the same error 3251.

Well if anyone has any insight into this I would appreciate it.
Dear why ru using DAO thry to use ADO. Its now the best option databridge
Mar 7 '07 #4
Killer42
8,435 Recognized Expert Expert
Dear why ru using DAO thry to use ADO. Its now the best option databridge
That does seem to be the consensus of opinion - that ADO is much superior. On the other hand, if you already have something that works, why change it?
Mar 7 '07 #5
willakawill
1,646 Top Contributor
Dear why ru using DAO thry to use ADO. Its now the best option databridge
I agree with Killer on this. I don't think it is useful to recommend completely changing all of the code just because of a bug in one line.
Mar 7 '07 #6
vijaydiwakar
579 Contributor
See this is not the question of one line bug
if he use ADO then in future also he is able to get the maximum facility given by the ADO. Programming is not the game of just coading its the game of visualization if ur not able to visualise the problem then its of no use.
If M$ alredy given us such advance utilities then why should we go for older one
Mar 7 '07 #7
willakawill
1,646 Top Contributor
See this is not the question of one line bug
if he use ADO then in future also he is able to get the maximum facility given by the ADO. Programming is not the game of just coading its the game of visualization if ur not able to visualise the problem then its of no use.
If M$ alredy given us such advance utilities then why should we go for older one
Because you never ever have a need to change something that works. In this case a part of the code does not work most likely because of the syntax and not because of the type of objects used.
Mar 7 '07 #8
Killer42
8,435 Recognized Expert Expert
Because you never ever have a need to change something that works. In this case a part of the code does not work most likely because of the syntax and not because of the type of objects used.
Yes, I think you have to consider the amount of effort involved in rewriting an entire application, just because there might be some benefit, some time in the future.
Mar 7 '07 #9
richardhodge
2 New Member
Well removing the ( ) from around tdf fixed the problem. The strange thing is that I know I tried that before and it still had problems at the exact same location. Oh well it seems to be working now and I have been testing it for over an hour now with no problems.

As far as switching to ADO that is something that will be happening in the next few months. Personally I prefer ADO, but the company has invested so much time into the current product, which was originally written in MS Access not in vb6 that they did not want to switch to ADO until we convert to VB.net this year.

Oh well I guess that is life.

Thanks again for all of the help. I knew it had to be something stupid, but then again the biggest bugs normally are something stupid.
Mar 7 '07 #10

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

Similar topics

3
4922
by: leroybt.rm | last post by:
Can someone tell me how to run a script from a interactive shell I type the following: >>>python filename >>>python filename.py >>>run filename >>>run filename.py >>>/run filename >>>/run filename.py
2
2530
by: Jenna Olson | last post by:
Hi all- I've never seen this particular issue addressed, but was wondering if there's anything to support one way or another. Say I have a class: class ManipulateData { public: ManipulateData(const char* Path-To-Some-Text-File) { ... }
15
4277
by: mg | last post by:
How can I run an .exe using C# from within the code behind of a WebForm app?
6
20065
by: orekin | last post by:
Hi There I have been trying to come to grips with Application.Run(), Application.Exit() and the Message Pump and I would really appreciate some feedback on the following questions .. There are quite a few words in this post but the questions are actually quite similar and should be fairly quick to answer ... (1) What is Happening with the Threads
6
2627
by: billr | last post by:
I have developed a small API for taking care of a lot of boiler plate stuff in a multi formed windows application, for example setting up a messaging thread framework. New Forms, in the appllication using the API, are subclassed to a Form contained within the API, and they are controlled (controlled in this instance means, kept alive, displayed and hidden) at runtime by a thread whose responsibility is this sole task. In order to run...
13
5072
by: Bob Day | last post by:
Using vs2003, vb.net I start a thread, giving it a name before start. Code snippet: 'give each thread a unique name (for later identification) Trunk_Thread.Name = "Trunk_0_Thread" ' allow only 1 thread per line Trunk_Thread.ApartmentState = ApartmentState.STA
19
2215
by: Bryan | last post by:
How can i run a bit of code straight from the IDE? Right now i make a temporary button and put the code behind that, then i run debug mode and click on the button. Is there a way to highlight some code and tell it to run that? Is there a "scratchpad" type window like in VBA where I can write some simple code to be executed? Thanks for the help in advance
7
2938
by: Lee Crabtree | last post by:
I remember when I was first getting into .NET Forms programming that there was a rather emphatic rule about not constructing a form before calling Application.Run with it. So this: Application.Run(new Form1()); was okay, but this: Form1 form = new Form1();
8
3005
by: David Thielen | last post by:
Hi; In our setup program how do I determine if I need to run "aspnet_regiis –i" and if so, is there an API I can calll rather than finding that program on the user's disk and calling it? -- thanks - dave david_at_windward_dot_net http://www.windwardreports.com
7
11739
by: mxdevit | last post by:
Task: run application from ASP.NET for example, you have a button on ASP.NET page, when press this button - one application is invoked. the code to run application (for example, notepad) is (on C#) System.Diagnostics.Process.Start("notepad");
0
8256
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8694
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8635
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8497
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6118
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4089
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1500
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.