Wrox Programmer Forums
|
BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5
This is the forum to discuss the Wrox book Beginning Visual Basic 2005 Databases by Thearon Willis; ISBN: 9780764588945
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 19th, 2011, 01:18 PM
Registered User
 
Join Date: Dec 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Smile SQLOLEDB Connection Error

As Chapter 2 I tried to connect SQL Database using below connection string and that was not successful. I' using SQL 2005 Express edition and visual basic 2005 professional edition. My SQL Server Named Instants is ".\Local" and i already have database i was created named "cash". here is my code:

***** This Access Code is working and below SQL connection code not working *******


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strOleDbConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Users\Sagara\Documents\Visual Studio 2005\Projects\OleDB_Proj\ProjectTimeTracker.MDB;"
Dim Conn As OleDbConnection = New OleDbConnection(strOleDbConn)
Try
Conn.Open()
MsgBox(Conn.State.ToString)

Catch ex As Exception

Finally
Conn.Close()
MsgBox(Conn.State.ToString)
Conn.Dispose()
Conn = Nothing

End Try
End Sub


**** This is the code not working ********

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'TODO : Please Check with this code wrox forum
Dim strSQLOLE As String = "Provider=SQLOLEDB;Data Source=.\Local;Database=Cash;"
Dim Conn As OleDbConnection = New OleDbConnection(strSQLOLE)

Try
Conn.Open()
MsgBox(Conn.State.ToString)

Catch ex As Exception
MsgBox(ex.ToString)

Finally
Conn.Close()
MsgBox(Conn.State.ToString)
Conn.Dispose()
Conn = Nothing

End Try
End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
Remote Connection Error: Named Pipes Provider error hbansal ASP.NET 2.0 Basics 5 April 12th, 2009 09:51 AM
DSN vs SQLOLEDB joemama SQL Server ASP 1 June 1st, 2006 03:46 PM
stored procedures and sqloledb terre SQL Server ASP 11 November 22nd, 2004 07:27 PM
sqloledb vs sqloledb.1 ckepford SQL Server ASP 3 November 9th, 2004 02:03 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.