| | |
VB.NET Database Connection Problem
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jan 2009
Posts: 21
Reputation:
Solved Threads: 0
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
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
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.
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.
Teme64 @ Windows Developer Blog
![]() |
Similar Threads
- vb.net database connection (VB.NET)
- Creating sql database connection in asp.net web application through C# (C#)
- Updated : Simple ASP.Net Login Page (ASP.NET)
- database connection for sql server 5.0 and vb.net (VB.NET)
- connection problem via driver (MS SQL)
- How to using a variable in a database connection (Visual Basic 4 / 5 / 6)
- Crystal report setconnection and parameter problem (VB.NET)
- JNDI/JDBC lookup problem with Sun Java Application Server 8.2 (Java)
Other Threads in the VB.NET Forum
- Previous Thread: Common References not recognised in VS2008
- Next Thread: Get Selected Item
| Thread Tools | Search this Thread |
.net .net2008 2008 access add advanced application array assignment basic beginner box browser button buttons center click code combo cpu cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic editvb.net employees excel exists fade filter forms html images isnumericfuntioncall listview map mobile module msaccess mssqlbackend mysql net number objects open pan panel pdf picturebox picturebox2 port position print printing printpreview record regex reuse right-to-left save search serial settings shutdown socket sorting sqldatbase sqlserver storedprocedure survey temp temperature textbox timer timespan transparency txttoxmlconverter usercontol vb vb.net vba vbnet vista visual visualbasic visualbasic.net visualstudio.net web winforms wpf wrapingcode xml year





