943,544 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 1636
  • VB.NET RSS
Jan 9th, 2009
0

VB.NET Database Connection Problem

Expand Post »
Dear all,

I have created an SQL Server 2005 Express database using the database explorer of VB.Net 2005, and selected to copy the database to the application folder.

I can successfully connect and update the tables using Visual Basic ready tools (such as datagrid). But when I try to connect to the same database by code I fail. The debugger always stops at the connection line which I apparently write it incorrectly.

What would this connection command be if the database is called 'Inventory.mdf' and located at 'C:\Inventory\Inventory.mdf'?

Thanks for help in advance
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Datsun90 is offline Offline
22 posts
since Jan 2009
Jan 9th, 2009
0

Re: VB.NET Database Connection Problem

First, you never ever connect to a database file (*.mdf) directly. You connect to the database, which knows where it's files are and handles them.

I didn't have a good (simple) example how to connect to the SQL Server. So I'll give you few links to get started. First you'll need to get familiar with System.Data.SqlClient namespace. Second thing to learn are connection strings.

Objects that you need to make a basic SQL Server connection and get the basic "functionality" are Connection and Command from the System.Data.SqlClient namespace. I also assume you're familiar with SQL. If you're not, try to google some SQL tutorial.
Reputation Points: 218
Solved Threads: 201
Veteran Poster
Teme64 is offline Offline
1,024 posts
since Aug 2008
Jan 13th, 2009
0

Re: VB.NET Database Connection Problem

Reputation Points: 10
Solved Threads: 9
Junior Poster
sierrainfo is offline Offline
144 posts
since May 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Common References not recognised in VS2008
Next Thread in VB.NET Forum Timeline: Custom Control, with a heading and an editable region!!!!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC