Swap Database in visual studio from Access to SQL - sql

I have created a windows form project which is based in vb.net in Visual Studio. This form acts as the front end to the database.
I decided this time round to try use the Dataset Designer in Visual Studio and found it convenient. Using the Wizard I linked up the MS Access database to create the Dataset in the project. This then automatically generated all the relevant table adapters, datasets, bindingsources and so on.
Now, the aim is to transition the same Access database to SQL-server.
The Question is whether it is possible to simply swap the Dataset in Visual Studio to from Access to SQL which have the same table names, structure, relations... I tried modifying the connection string in Settings.settings with no success.
This would save me a lot of time from going through each object and updating the datasource to the new SQL database.

You should be able to establish a separate connection to sql server using ado. You can find typical connection strings easily: try http://www.connectionstrings.com/microsoft-ole-db-provider-for-sql-server-sqloledb/ for example. If the tables exist in sql server, you can SELECT from Access and INSERT into SSvr using 2 different connections, 2 sql command objects. If you have trouble with the SQL (which is very possible, I have not done this with Access), create a dataset from the Access SELECT and use that as an intermediate step. If the tables do not exist yet, get the script for CREATE TABLE in Access or in SSMS, and execute that before doing the SELECT/INSERT operation.

Related

Excel OBDC - SQL Query

I am trying to use Excel pull data from a large Oracle Data Warehouse via an ODBC connection. I have a query that works using the editor in Access. I've tried using Power Query and Microsoft SQL to use this query to get this data into Excel and I get errors.
Therefore:
Does SQL executed from Excel need to be in a different syntax? Shouldn't it still be Oracle?
How can I use this pre-written query to ping the data warehouse and get what I need?
Here is the SQL that I have so far. I had to change some table names...sorry if that makes it weird.
The SQL you posted uses Access-specific functions. That is NOT a valid SQL query if run directly against Oracle. If you have a bunch of linked tables in Access, that would allow this.
The ODBC datasource connection in Excel works differently. ODBC executes the query directly at the datasource. It does some validation first and supports a limited subset of SQL language supported at the destination. What's included in the subset is determined in part by the driver selected for the connection.
So what you want to do is use a tool that lets you build the query directly in an Oracle environment, like Quest Toad or Oracle SQL Developer. Once you have the query working there, it should be easier to port it to Excel.
One thing I like to do is put my query into a view on the database. Then I can just select everything from the view when creating the Excel connection.
It's also worth pointing you to the My Data Sources folder. When you first setup an ODBC connection in Excel, the connection is saved by default in Windows in a folder called "My Data Sources" located just under your user profile folder. For example: C:\Users\UserName\My Data Sources\Data Source Name.odc.
You can open these *.odc files in any text editor, and you should be able to manually edit the SQL here. Especially look for the <odc:CommandText> element. In this way you can build a simple query up front, and then improve on the SQL command in your favorite environment and easily move the updated SQL to the existing ODBC connection.

How do I add records from an Access database into an existing SQL Server database?

I have an existing Access database that has out grown it's usefulness. I have written a Visual Basic program that uses a SQL Server database and have been re-entering the data from the Access file into SQL Server individually.
I still have 300+ records to move and would like to find a way to do all this using either a data snippet in Visual Basic, or using SQL Server Express. I'm smart enough to set up and use Access, and smart enough to create a program and database in Visual Basic and SQL Server but for some reason I not smart enough to move the records between the 2 databases.
When I originally created the .mdf file I attempted to move the records at that time but everything I tried didn't work so I figured I'd get it later, but now I have 300+ records in the .mdf file and need to get the others moved over. Anybody have any ideas?
Easiest thing to do is create your database, then in SSMS's Object Explorer, right click on the database, Tasks -> Import Data ... and go through the Import/Export wizard, selecting MS Access as your source.

Linking An Access DataBase to Sql Building and building VB InterFace

Hey IO have an old access data base and I have reeated the New data base using SQL Server Management Studio but all the data is still in the Access data base and I was wondering how to link these two. I have been trying to create the linked tables in access using the ODBC tool but none of the table I want are appearing?
Was wondering if anyone has any ideas on how I can do this?
Also I then have started to create the front end of the database using Visual Studio but cant get the fields to populate as the SQL database currently has no data linked to it
Instead of linking tables have you considered using SQL Server Express (you did not mention what the 'new database' is, assume Access?) and the data import wizard to port the data to SQL Server? You get all the tools by downloading 'SQL Server with tools' from Microsoft. And use SSMS for management functions, it is much easier than the Visual Studio interface.

How to view and change data of a .mdf file using MS Access?

Background: I have an .mdf database containing some numeric values that I need to change (specifically, scale and offset values for sensors). The database was created by a Visual Basic program that controls some lab equipment and stores pertinent data in the .mdf file. Please excuse my rudimentary knowledge of the topic; I'm a complete novice when it comes to SQL Server and VB.
After searching through many posts, I understand that to open the .mdf file, you must "attach" it in Microsoft Server Management Studio (I'm using that with SQL Server 2005), which I have successfully done.
Problem: It seems that this only allows me to view and modify the structure of the database, ie. tables, columns, data types etc., rather than the values of the database itself.
Is there a way to do this manually, like how you can edit the field data of .mdb files in MS Access? Again, sorry for my limited knowledge on the topic. I'll gladly provide extra details where needed.
You mention you want to use access. That can be done. Your database is up and running after attaching it.
In Access you can simply create an ODBC connection in access and use Access to edit/modify your data as much as you want. you can also create queries.
It is in the menu item "external data" [I'm guessing because I use a dutch version]. You select to create a "linked table", choose your server and you are done.
Right-click on the table you want to modify in SSMS and select "Edit Top 200 Rows".
If you have more than 200 rows to edit, you can connect to the SQL Server database with either Access or Excel.
Here are the instructions for Access:
http://office.microsoft.com/en-us/access-help/connect-an-access-project-to-a-microsoft-sql-server-database-adp-HP005274586.aspx

References/walkthroughs for maintaining database schemas with Visual Studio 2010?

I have Visual Studio 2010 Beta 2 and SQL Server 2008 installed. I'm working with a populated database and want to modify various column types. SQL Server Management Studio requires me to drop tables to do this, and get pretty finicky given my moderate level of knowledge of SQL Server.
However, I heard the new database project type supports changing the database schema to the desired format and it will handle creating and running all the scripts to implement the changes.
I've created a VS2010 database project using the existing database as the source, but so far haven't had much luck figuring out the appropriate method to make the changes without getting an error.
As a result, I'm looking for any reference info I can find on using VS2010's capabilities in this area. Any suggestions?
write scripts instead of using the gui. You can use alter table for instance to change a column. Never use a GUI of any kind to create a change to a database table.
Here's a walk through of the new VS2010 "Deploy-SQL" tab in the properties page of web application projects.