A little background first. Where I work we have limited access to programming tools. We have access to the Microsoft Office Suite and therefore most of our projects are created in Access even though there are better solutions out there. We recently received access to Visual Studio 2013 and I am interested in converting some of our more heavily used tools into VB.NET projects.
I have a good understanding of VBA after using it for so many years, however, converting to VB.NET is definitely a change and although I understand the concept of it, many of the functions I used in the past do not exist in VB.NET.
Which leads me to the following question.
How do I connect to one database, an ODBC connection, then put selected fields from a table in that database to a table in a Microsoft Access database?
Here is my current code.
Clearly this is not going to work. I have tried a few things based on examples on the Internet but have been unable to piece together any kind of code that works.
When using the Access database I would simply link to the tables in both the ODBC connection and the backend Access database and then I could use DoCmd to run SQL to move data as needed, however with VB.NET I don't have that luxury. Perhaps I am going about this all wrong due to my lack of knowledge with Visual Studio.
Is there a better way to accomplish my end goal? I need to be able to refer to the data in the ODBC connection and then store it somewhere so that I can output a specific dataset to the end user. Can/should I use a DataSet or DataTable? How much data can be stored in a DataSet/DataTable before the program would become unstable? The data used in this process can be quite excessive at times.
Typically the user would send the tool some criteria with 4 or 5 fields worth of data. The tool will then turn around and take that criteria to get the proper dataset from the ODBC connected database using joins on about 5 to 7 tables and returns one set of data to the user. Yes, it is a bit excessive, but that's the requirement.
I hope I am explaining this well enough without being too generic. The nature of my business prevents providing specific examples.
Sorry for being longwinded and I appreciate any effort that goes into helping me solve this issue. If there is anything that needs to be clarified please let me know and I will try to explain it more clearly.
Ňɏssa Pøngjǣrdenlarp35.7k1111 gold badges4141 silver badges114114 bronze badges
Randy ToyeRandy Toye
2 Answers
Odbc Microsoft Access Setup
You may find it helpful to be aware that when you run a query against the Access Database Engine from a .NET application you can use ODBC references in your queries and the engine will perform the required ODBC connections for you. In effect, these are temporary 'on the fly' ODBC linked tables created for that specific query.
Say we have a table named [product] in SQL Server
and we can reach that SQL Server instance via an ODBC DSN named 'myDb'. We can reference that table from an Access query as
So, for example, if we want to query an Access table named [Orders]
and pull in the product names from the SQL Server table named [product] we can do this in VB.NET:
which prints
Gord ThompsonGord Thompson81.1k1414 gold badges106106 silver badges241241 bronze badges
First of all, I need to ask about the original source for your
SLICWave
ODBC connection. Is it still in Access, or are you perhaps pulling from Sql Server or similar at this point? ODBC is going to pass your command statement on to the original source, and if you're using Sql Server now, instead of Access, some of the SQL syntax will change on you.For the remainder of the question, I'll assume the SQL you have will work if executed. If it turns out you need help converting that to T-SQL for SQL Server, open a separate question limited to that specific problem.
That out of the way, I'm now going to limit my scope to this statement:
I need to be able to refer to the data in the ODBC connection and .. output a specific dataset to the end user.
What you want to do is put a
Joel CoehoornJoel CoehoornDataGridView
control on your form (I'll use the default DataGridView1
name for now). Then make the form code look like this:317k9999 gold badges505505 silver badges740740 bronze badges
Not the answer you're looking for? Browse other questions tagged vb.netms-access or ask your own question.
A little background first. Where I work we have limited access to programming tools. We have access to the Microsoft Office Suite and therefore most of our projects are created in Access even though there are better solutions out there. We recently received access to Visual Studio 2013 and I am interested in converting some of our more heavily used tools into VB.NET projects.
I have a good understanding of VBA after using it for so many years, however, converting to VB.NET is definitely a change and although I understand the concept of it, many of the functions I used in the past do not exist in VB.NET.
Which leads me to the following question.
How do I connect to one database, an ODBC connection, then put selected fields from a table in that database to a table in a Microsoft Access database?
Here is my current code.
Clearly this is not going to work. I have tried a few things based on examples on the Internet but have been unable to piece together any kind of code that works.
When using the Access database I would simply link to the tables in both the ODBC connection and the backend Access database and then I could use DoCmd to run SQL to move data as needed, however with VB.NET I don't have that luxury. Perhaps I am going about this all wrong due to my lack of knowledge with Visual Studio.
Is there a better way to accomplish my end goal? I need to be able to refer to the data in the ODBC connection and then store it somewhere so that I can output a specific dataset to the end user. Can/should I use a DataSet or DataTable? How much data can be stored in a DataSet/DataTable before the program would become unstable? The data used in this process can be quite excessive at times.
Typically the user would send the tool some criteria with 4 or 5 fields worth of data. The tool will then turn around and take that criteria to get the proper dataset from the ODBC connected database using joins on about 5 to 7 tables and returns one set of data to the user. Yes, it is a bit excessive, but that's the requirement.
![Odbc Odbc](/uploads/1/2/3/7/123708957/725086458.jpg)
I hope I am explaining this well enough without being too generic. The nature of my business prevents providing specific examples.
Sorry for being longwinded and I appreciate any effort that goes into helping me solve this issue. If there is anything that needs to be clarified please let me know and I will try to explain it more clearly.
Ňɏssa Pøngjǣrdenlarp35.7k1111 gold badges4141 silver badges114114 bronze badges
Randy ToyeRandy Toye
2 Answers
You may find it helpful to be aware that when you run a query against the Access Database Engine from a .NET application you can use ODBC references in your queries and the engine will perform the required ODBC connections for you. In effect, these are temporary 'on the fly' ODBC linked tables created for that specific query.
Say we have a table named [product] in SQL Server
and we can reach that SQL Server instance via an ODBC DSN named 'myDb'. We can reference that table from an Access query as
So, for example, if we want to query an Access table named [Orders]
and pull in the product names from the SQL Server table named [product] we can do this in VB.NET:
which prints
Gord ThompsonGord Thompson81.1k1414 gold badges106106 silver badges241241 bronze badges
First of all, I need to ask about the original source for your
SLICWave
ODBC connection. Is it still in Access, or are you perhaps pulling from Sql Server or similar at this point? ODBC is going to pass your command statement on to the original source, and if you're using Sql Server now, instead of Access, some of the SQL syntax will change on you.For the remainder of the question, I'll assume the SQL you have will work if executed. If it turns out you need help converting that to T-SQL for SQL Server, open a separate question limited to that specific problem.
That out of the way, I'm now going to limit my scope to this statement:
I need to be able to refer to the data in the ODBC connection and .. output a specific dataset to the end user.
Koneksi Vb6 Odbc Access Db Error
What you want to do is put a
Joel CoehoornJoel CoehoornDataGridView
control on your form (I'll use the default DataGridView1
name for now). Then make the form code look like this:317k9999 gold badges505505 silver badges740740 bronze badges
Not the answer you're looking for? Browse other questions tagged vb.netms-access or ask your own question.
I tried My best to add ODBC System Data Source for Access (.accdb) Database using VB.NET. Searching from Google I tried many Functions but nothing worked.
Code I tried is :
Error is :
A call to PInvoke function 'j!j.Form1::SQLConfigDataSource' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
Please Help.
Tim25.9k66 gold badges5353 silver badges6262 bronze badges
JenitJenit
1 Answer
Without seeing your
<DllImport>
statement, it's difficult to give you an exact answer, but I'm making an educated guess (based on sqlconfigdatasource (odbccp32) at pinvoke.net) and the code you provided that you've defined your SQLConfigDataSource
function as something like this:When in reality
hwndParent
is an 32-bit integer (Integer
in VB.NET), so it should look something like this:Apr 21, 2014 - Hitman Blood Money Free Download PC game setup in direct single link. Its an action and shooting game. Save your agency members from. Hitman Blood Money Free Download PC game setup in direct single link. Its an action and shooting game. Save your agency members from enemies Hitman. Hitman blood money download ocean of games 3gb to mb. Hitman Blood Money Free Download PC game setup in direct single link. Its an action and shooting game. Save your agency members from enemiesHitman. Hitman Blood Money Free Download PC game setup in direct single link. Its an action and shooting game. Save your agency members from enemies.
The you would call it like this:
Note
0
is an Integer
, whereas 0&
is a Long
.EDITFrom pinvoke.net:
Then simply replace your current line
With this:
Vb6 Odbc Sample
TimTim25.9k66 gold badges5353 silver badges6262 bronze badges
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.