VB.NET Database Connection Problem

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2009
Posts: 21
Reputation: Datsun90 is an unknown quantity at this point 
Solved Threads: 0
Datsun90 Datsun90 is offline Offline
Newbie Poster

VB.NET Database Connection Problem

 
0
  #1
Jan 9th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: VB.NET Database Connection Problem

 
0
  #2
Jan 9th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 144
Reputation: sierrainfo is an unknown quantity at this point 
Solved Threads: 9
sierrainfo sierrainfo is offline Offline
Junior Poster

Re: VB.NET Database Connection Problem

 
0
  #3
Jan 13th, 2009
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC