Convert Access data base to SQL Server - asp.net

I've created an application using ASP.NET with Access DB, now I found somee.com who support only SQL Server DBs, so Now I must convert my Access DB to SQL Server DB.
Is there any tool who can do the trick ?
This is some code I'm using in my web application :
Public Shared Function conecter() As OleDbConnection
Dim MyConnexion As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & System.AppDomain.CurrentDomain.BaseDirectory & "/Learning.mdb")
MyConnexion.Open()
Return MyConnexion
End Function
Public Shared Function lecture(ByVal requete As String) As OleDbDataReader
Dim Mycommand As OleDbCommand = conecter().CreateCommand()
Mycommand.CommandText = requete
Dim myReader As OleDbDataReader = Mycommand.ExecuteReader()
Return myReader
End Function
In this case, If I convert my database I must change the OleDbConnexion and other things or I can just leave them like that ?

Your connection string will need to change. Connectionstrings.com is a good resource for this if you're having problems figuring out how to set up a SQL connection string.
For upward migration, take a look at the Access Upsize Wizard - this link is for 2002 since I'm not sure what access version you have.
If for some reason you do not have sufficient access to your SQL database to handle an upsize directly, you'll likely need to just generate the database schema and knock out a bit of migration code.

If you have access 2007, there is inbuilt option convert access database to SQL other wise there are somany tools available for free.
bullzip free converter

Try MUST
It was developed by a colleague of mine (we designed the website: www.upsizing.co.uk).
It does a fair bit more than the MS tools.

Related

Connecting MS SQL DataBase To GODADDY host

I am new to uploading websites online, I have uploaded my website to Godaddy host and run perfectly but i don't know how to connect my MS Sql Data base and how to configure my connection string ! can any one help me or give me a tutorial of how doing this starting from a normal MS sql Database with normal connection string(Local DB and Local connection string) until uploading it online ?
Connecting to a sql server database on go daddy works the same way as connecting to any other Sql Server db from a .Net perspective.
Log in to your go daddy account to get the connection string info. There's even code samples in there for how to configure your connection string.
Alos, here's a link about .net connection strings in general
http://msdn.microsoft.com/en-us/library/jj653752(v=vs.110).aspx
One of the advantages of using MS SQL is that you can use the SqlClient native libraries, which are faster than ODBC, etc.
using System.Data;
using System.Data.SqlClient;
public class Demo {
public DataTable ConnectAndQuery() {
SqlConnection cn = new SqlConnection("Data Source=IP-GOES-HERE;Initial Catalog=YOUR-DATABASE-NAME-HERE;user id=DB-USER-HERE;password=DB-PASS-HERE;Connection Timeout=300");
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM TableName", cn);
DataSet results = new DataSet();
da.Fill(results);
return results;
}
}
I usually store my connection strings in the web.config. There's actually a specific section you can store them in, if you'd like. Here's an example of that:
http://msdn.microsoft.com/en-us/library/dx0f3cf2(v=vs.85).aspx

How to access SQL Server from my WCF web service?

VS Express 2012, SQL Server Express 2012, Win 8.1
Hello,
I have a (very) simple WCF hosted as a web service on IIS. I also have a SQL Server instance (with 1 table) installed on the same machine.
I need a step-by-step guide on how to connect to SQL from the WCF (VB) and retrieve a single record from the table (ie: "SELECT LAST NAME FROM MYTABLE WHERE PK = 1;"). That's it. I don't need a 1,200 page manual -- which is all Google keeps throwing at me.
Anyone know of a quick, clean resource?
Thanks,
Jason
The main classes that are involved are SqlConnection and SqlCommand. The documentation of the classes contains some samples on how to use them. To get you started, here is a small sample:
Dim connStr = "Data Source=SQLServerName\InstanceName;Initial Catalog=DatabaseName;Integrated Security=SSPI"
Using conn As New SqlConnection(connStr)
conn.Open()
Using cmd = conn.CreateCommand()
cmd.CommandText = "SELECT LAST_NAME FROM MYTABLE WHERE PK = #pk"
cmd.Parameters.AddWithValue("#pk", 1)
Dim result = cmd.ExecuteScalar()
If Typeof result Is DbNull Then
' Handle null value
Else
' Otherwise
End If
End Using
End Using
This sample assumes that you want to retrieve a single cell as in your statement. If you want to retrieve tabular data, have a look a the SqlDataReader or SqlDataAdapter class.
Please note that - especially in server applications - it is important to dispose of the created instances properly.
There is no difference on using ADO.NET in a WCF service or in a normal application from the point of view of the classes required.
The first thing needed is a connection string that allows your SqlConnection object to find the host and the database that you want to use. Here examples on connection strings
Then you usually need a SqlCommand that encapsulates the SQL text and parameters needed to retrieve the data (Here you setup your SELECT statement and conditions)
Finally you need a SqlDataReader that get the result of the command execution and allows you to loop over the results.
Here a sample that could get you started.
Keep in mind that this is just a minimal todo-list and there are numerous other ways to work with data. Basic objects like SqlDataAdapter, Dataset, DataTable present different ways to load data from a database and use that data. Then on top of these there are technologies like Linq To Sql and Object Relational Mapper tools that abstract the data access and offer high level functionality on top of data.
That's probably the reason you get so much informations on data access technologies

Connect to SQL server using Linq, asp.net

I`m creating a website using asp.net, and I need to use a local SQL server (using Microsoft SQL server). And I have created database and tables in it using the MS SQL Server Management Studio.
Now I successfully connect to the database and do some simple add/query using the following commands:
string connectionString = "data source=ABCD\\SQLEXPRESS;initial catalog=PMD;Trusted_Connection=yes;";
string sqlQuery = "INSERT INTO PMD (username, userID, userAddress)";
sqlQuery += " VALUES (#user, id, add)";
SqlConnection dataConnection = new SqlConnection(connectionString);
SqlCommand dataCommand = new SqlCommand(sqlQuery, dataConnection);
dataCommand.Parameters.AddWithValue("user", USER.Value);
dataCommand.Parameters.AddWithValue("id", ID.Value);
dataCommand.Parameters.AddWithValue("add", ADDRESS.Text);
dataConnection.Open();
dataCommand.ExecuteNonQuery();
dataConnection.Close();
The command above can add one column to the table, with values stated.
The query is done in a similar way. Compared with Linq, this is not very concise.
So I was wondering how can I change the code so I can use Linq.
The biggest question for me now is how to connect to the base. I already know all the syntax of Linq.
eg: var query=from c in db.username where c.Contain(“Micheal”) select c (or maybe db.PMD.username)
How can I get the db to link with ABCD/SQLEXPRESS, table PMD?
First you need an Object/Relational Mapper (O/RM). You can't just put LINQ on top of your old ADO.NET code.
Microsoft provides two: Linq2SQL and Entity Framework.
Linq2SQL has been discontinued. If I had to choose between the two, I'd go with Entity Framework.
Here you can find an introduction: http://www.asp.net/entity-framework
For example, install Entity Framework, then connect to sql server with entity framework

classic asp async sql execution

I have a classic asp application (ASP 3.0 running on Windows 2000/IIS 5.0) which allows users to write custom SQL queries to fetch data from the database (Oracle 10g), more like SQL Developer. Sometimes users write complex queries which runs indefinitely, though the user would click the back button to go back to previous page, the query might still run on the database. Now users are requesting they be given a functionality to kill the query on a click of a button.
I am beginner in asp, so I am not sure if this is possible in asp. We are using ADODB.RecordSet object to fetch the data using RecordSet.Open and RecordSet.GetRows. Please advise if this is achievable in classic asp.
Set connection = Server.CreateObject("ADODB.Connection")
connection.Open DATA_SOURCE, LOGON_ID, PASSWORD
Set resultset = Server.CreateObject("ADODB.Recordset")
Dim sql
sql="select sysdate from dual"
resultset.Open sql, connection
Dim DBData
DBData = resultset.GetRows(NUMROWS)
resultset.close
connection.close
Set resultset = Nothing
Set connection = Nothing
Try this
arrayRs = resultset.GetRows()
if arrayRs(0,0)<> "" then
response.write(arrayRs(0,0))
end if
Or you can try a loop when you are fetching more than one field

asp.net: Is sqlConnection ADO?

Is sqlConnection ADO, if not, what's the name of the layer?
To invoke ADO, (to access non-MS db's), is OleDbConnection the prefered choice?
SqlConnection is part of the ".NET Data Provider for SQL Server", so it is ADO.NET, not to be confused with the old COM-based ADO.
Also, yes I believe OleDBConnection is preferred for Access. I do not believe there is an out-of-the box native data provider for MS Access.
1) The SqlConnection Class is part of the System.Data.SqlClient namespace, and is considered part of ADO.NET.
2) OleDbConnection is for connecting to OLE databases. If you're talking about building a platform-agnostic data access layer, you should use System.Data.Common.DbProviderFactories to create generic DbConnection, DbCommand, etc, objects as in the following code example:
Dim objFactory As DbProviderFactory = DbProviderFactories.GetFactory(ConfigurationManager.AppSettings("DbType"))
Dim objConnection As DbConnection = objFactory.CreateConnection
objConnection.ConnectionString = strConnectionString
In this example, you'd keep the name of the actual provider you're using in your Application Settings.
Note that the generic DB objects only support lowest-common-denominator methods so if you're looking for something platform-specific, you're out of luck. Also of course you will have to specify a valid DBtype to the provider factory, which means you'll have to use either one of the built in providers (ODBC, MS SQL, Oracle, OLEDB) or a third party one. I think you could get away with ODBC if you have a ODBC driver for your platform, but I don't know much about that one.
For information on the different connection objects included in ADO.NET: MSDN-Connecting to Data Sources
Yes it is part of ADO.NET. If you use SqlConnection, actually it is a part of ADO.NET to make a connection between your application and database.

Resources