Showing posts with label oledbconnection. Show all posts
Showing posts with label oledbconnection. Show all posts

Thursday, March 22, 2012

Connectionstring problem

Hay, I have a problem with this connectionstring.

Dim myConnectionAs New Data.OleDb.OleDbConnection("Provider=SQLNCLI;Data Source=whatever-ja4lbq\sqlexpress;Initial Catalog=Account;Integrated Security=SSPI;")
I use this code to receive a value on a specific query
 
Public Sub readdata(ByVal myconnectionstringAs String)Dim mySelectQueryAs String = "SELECT UserName, Password FROM TAccount WHERE UseName ='" & TextBox1.Text & "'; and Password = '" & TextBox2.Text & "';"Dim mycommandAs New Data.OleDb.OleDbCommand(mySelectQuery, myConnection) myConnection.Open()Dim myreaderAs Data.OleDb.OleDbDataReader myreader = mycommand.ExecuteReaderWhile myreader.Read Label1.Text = myreader.GetString(1)End While myreader.Close() myConnection.Close()End Sub 
 
But when it execute i receive this exeption
 
Login timeout expired
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.
SQL Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF].
 
Is this mean that i can not make a connection to my sql server 2005.

My sql server 2005 runs on my developer computer

 

By default SQL Server 2005 does not allow remote connections. Select Start -> All programs-> Microsoft SQL Server 2005 -> Configuration Tools -> SQL Server 2005 Surface Area Configuration. When the tool opens, pick "Surface Area Configuration for Services and Connections", when you get a tree view of all configurable services. Under "Database engine", there's a "remote connections" leaf, from which you can enable remote connections. You need also turn Sql Server Browser service on (since you use instance name in connection string)

More information:http://support.microsoft.com/kb/914277

|||

And i must make some permission properties in my databases

Thanks

Tuesday, February 14, 2012

connection sql server problems

What is the problems of my code to connect sql database below : thx!
Code:
Dim objConn As New OleDbConnection()
objConn.ConnectionString = "Data Source=localhost;IntegratedSecurity=SSPI;user id=sa; password=sa;Initial Catalog=rental"

objConn.Open()
Error :

An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB;'.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details:System.ArgumentException: An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB;'.
Source Error:
Line 7: Line 8: Dim objConn As New OleDbConnection()Line 9: objConn.ConnectionString = "Data Source=localhost;IntegratedSecurity=SSPI;user id=sa; password=sa;Initial Catalog=rental"Line 10: Line 11: objConn.Open()
Your connection string is appropriate for a SqlConnection object. If you want to use an OledbConnection (which is slower), you'll have to specify Provider=sqloledb
Marcie