VS2008 project upgrade upgraded my database?

M

musosdev

Hi gang,

I've just opened one of my web projects (C#, .net 2.0) in VS2008 and ran the
conversion wizard.

Everything went ok, but the site won't work. My ConnectionString on all my
database connections is wrong. :(

I've just had a look, and notice that the Access MDB file the website used
seems to have been replaced/upgraded with an MDF file. Is this expected
behaviour?!

Unfortunately, it hasn't upgraded all my OLEDB connections.

Here's an example...

----------------------
// open the db
OleDbConnection dbConn = new
OleDbConnection(ConfigurationSettings.AppSettings.Get("System_ConnectionString"));
dbConn.Open();
OleDbCommand genreCmd = new OleDbCommand("SELECT genre_id, genre_name
FROM genres WHERE relates_to = 0 ORDER BY genre_name ASC", dbConn);
OleDbDataReader genreDR = genreCmd.ExecuteReader();
----------------

I've changed the connection string to see if it would accept the MDF file
(unlikely I know). It gave me the "unrecognised database format" error.

So the question is.... can I get the OLEDB commands to talk to the mdf
file!? If so, how? And if not, is there a quick way to change all my db
connection code to SQLConnections?!

Thanks,


Dan
 
J

Jialiang Ge [MSFT]

Hello Dan,

From your post, my understanding on this issue is: you wonder (1) how to
quickly edit some settings so that the OLEDB commands can talk to mdf file
and (2) why is mdb file upgraded to mdf when VS2008 Project conversion is
run. If I'm off base, please feel free to let me know.

For your first question "how to quickly edit some settings so that the
OLEDB commands can talk to mdf file", the answer is yes.
*.mdf is a kind of file used by sql server to store databases. If the mdf
file is valid (if the VS2008 project conversion does not fail to upgrade
the mdb to a valid mdf file), we can modify the connection string to use
SQL OLEDB connection, and there is no need to change the OLEDB command code.

For example, suppose the original connection string for the Access mdb file
is:
"Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=D:\
db1.mdb"
We need to change it to be:
"Provider=sqloledb;Server=.\; AttachDbFilename=d:\updateddb1.mdf;
Database=Student;Trusted_Connection=Yes; "
Where ".\" is my local sql server instance and "Student" is the database in
the mdf.
Please have a try and let me know if it works for you. If it the project
still fails to run, would you help to verify if the mdf is valid by loading
it directly into SQL Server (open SQL Server->All Tasks->Attach
Database->Select the mdf file)?

Apart from the suggestions above, I think we can consider using the
original mdb file by replacing the mdf with mdb. In this way, both the
connection string and OLEDB command code do not need to be modified.

For you second question "why is mdb file upgraded to mdf when VS2008
Project conversion is run.":
To be honest, I have tried a lot of methods to connect to a mdb file from
vs2005 project, and upgraded it to VS2008 project, but still failed to
reproduce the conversion from mdb to mdf. Our internal product issue
database and the MSDN article
http://msdn2.microsoft.com/en-us/library/60z6y467.aspx do not record the
behavior, either. Would you please tell us more information about the
connection setting of the original mdb file? Or would you mind sending a
small VS2005 web application project that can reproduce the issue when
upgraded to my mail box: (e-mail address removed)?

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jialiang Ge [MSFT]

Hello Dan,

Would you mind letting me know the result of the suggestions? Would you
mind letting me know how to reproduce the issue that mdb is converted to
mdf during the VS2005->VS2008 project conversion? Please feel free to let
me know your concerns and questions.

Have a great day!

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top