Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello,

I have written an address book and for its database, I used Access to create a .mdb database and store my data programmatically into this .mdb file.

However, the problem is that when reading and saving data to this kind of database I have to use Jet 4.0 which is NOT available on 64-bit systems and I have to compile my application as 32-bit in order to run on all systems.

I just want to know how is upgrade to SQL?

I never used SQL, can I create a stand-alone database file using SQL like Access and create tables/fields so I can modify it programmatically?

I also need the database file to be independent and don't need any special requirements to run on target systems, like the .mdb file I've created in Access!

Please advise :)

Posted

Thanks, well I use Microsoft.Jet.OLEDB.4.0 to work with Access files, this driver has NOT a 64-bit version.

I decided to switch to SQL Server Express 2008. So in my VB.NET 2008 with .NET Framework 2.0, what driver/referece should be used?

I think my code should remain intact or with minor changes, since I use SQL commands and they are the same in both?

 

--

 

For example this is one of my codes:

Dim StringConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=File.mdb;Jet OLEDB:Database Password = 12345"
Dim MyConnection As New OleDbConnection(StringConnection)
MyConnection.Open()
Dim ReadUsers As New OleDb.OleDbCommand("SELECT Name, Email, Title FROM Accounts", MyConnection)
Dim MyReaders As OleDbDataReader = ReadUsers.ExecuteReader
While MyReaders.Read
  MessageBox.Show MyReaders("SendingMethod").ToString
End While
MyReaders.Close()
MyConnection.Close()

  • Administrators
Posted
It would use System.Data.SqlCLient classes rather than the OleDb classes and the connection string would point to a sql server rather than be an ole db provider pointing to a jet database but the actual sql commands are by and large identical for the more common tasks.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

Hi and thanks for your professional comments :)

I am so glad you are here to help other people, God bless you! :p

Everything is going well, I have installed SQL Server Express 2008 and am re-creating my database and its tables...

However, there is one thing I cannot find it in the new environment.

 

In Access, when I create a new table, I am being asked to create a Primary Key, here's full message box:

-

There is no primary key defined.

Although a primary key isn't required, it's highly recommended. A table must have a primary key for you to define a relationship between this table and other tables in the database.

Do you want to create a primary key now?

-

I MUST press YES to create a Primary Key, how to do this in SQL Server 2008?

You know, Access automatically creates an "Auto Number" ID <Long Integer> and set it Primary Key.

While SQL Server 2008 won't do this or I cannot find it?

There is a Primary Key column for all fields but this does not seem to be what I want?

 

Can you please be so kind and help me once more?! :)

  • Administrators
Posted

To get the same effect as an autonumber field in sql simply declare the column has being an integer and then set it's identity property to true.

 

You can set the primary key by clicking on the little key button when the correct column is selected in the designer.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

Hi again:)

Do you have any idea what's the replacement for Memo data type in SQL Server?

Memo type does not have a field size... But it cannot be found in SQL Server 2008... :confused:

Posted

Hi PlausiblyDamp,

Thanks for all your help :)

Anyway there's a question in my mind if it's possible to read .sdf file from my VB.NET application on target systems WITHOUT SQL Server 2008 installed on them? Either it's not possible or I cound not figure its connection string after a lot of search on the web... :(

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...