-
basic help!!!
I am fresh on vb.net 2005 - i tried to develop a simple windows .net framework application and want to use sqlserver db into it. when i tried to use this code:
dim myConn as new SqlConnection
it doesn't recognizes and raise an exception to change it to:
dim myConn as new sqlClient.SqlConnection
when i use the sqlclient.sqlconnection and runs the application, it raise an error that its not working to call a client remote connection???
can anyone help me to write codes to:
- connect sqlserver db
- dataadapter, datareader etc?
cheers
-
Re: basic help!!!
Ok - where is the SQL server? Is it on your machine or on your network - or remote to your machine?
-
Re: basic help!!!
sql server express 2005 is installed on my pc along with vs2005. my computer name is pc1 and database name is TEST under d:\testApp
hope its ok and thx in advance for next reply!
cheers
-
Re: basic help!!!
This is what I use to connection to an SQL Server database that is on our local network.
Code:
Imports System.Data.SqlClient
Public myConnection As SqlConnection
Public Sub OpenDB()
myConnection = New SqlConnection("Integrated Security=SSPI;" _
& "Persist Security Info=False;Initial Catalog=XXXXXXX; " _
& "Data Source=XXXXXXXXXX")
myConnection.Open()
End Sub
-
Re: basic help!!!
well thx but this doesn't work either. i m using the following codes:
Dim Database As String = "[test]"
Dim ServerName As String = "[local]"
Dim ConString As String = "Server=" & ServerName & ";Initial Catalog=" & Database & ";User ID=;Password="
Dim connection As New SqlConnection(ConString) ' connect to the db
Dim success As String
Try
connection.Open()
success = "sql connection successful..."
Catch 'errormessage
success = Err.Description
End Try
Dim form1 As New Form1
MsgBox(success)
end sub
it raise an exception error message saying:
an error has occured while establishing a connection to the server. when connection to sql server 2005, this failure may be caused by the fact that uneder the default settings SQL server does not allow remote connections. (provider: names pipes provider, error: 40 - could not open a connection to sql server)
any idea?
cheers
-
Re: basic help!!!
Seems odd that it's a local instance of sql giving you that error...
At any rate - do this.
Start>All Programs>Microsoft SQL 2005>Configuration Tools>SQL Server Surface Area Configuration
Select Surface Area Config Services and Connections
Expand the server node - database engine - Remote Connections
What is checked off?
-
Re: basic help!!!
its set on Local connections only while the other option Local and Remote connections is off
what to do?
cheers
-
Re: basic help!!!
Try setting it to Local and Remote connections.
-
Re: basic help!!!
no m8 - it doesn't work either!
Can u pls send me tips to use MS Access db instead of Sql Server? atleast i can get on to some stuff and try to resolve the sql server issue some other time?
cheers
-
Re: basic help!!!
well - the server name is not [LOCAL]
on my laptop - with a name of FPS-LAP-SZ - the SQL EXPRESS instance is called:
FPS-LAP-SZ\SQLEXPRESS