August 3, 2005 at 9:13 am
Hi ,
I am trying to connect to SQL server through ado.net.
When I make the connection using ‘server explorer ‘ msg shows that test connection succeeded.
But when that same connection is used in the code,
Exception is thrown stating that sql server doesn’t exist or access denied.
i am having sql client on my pc and server on other pc which is on network
i am having administrator privilleges on both systems.
If anyone can help me in this regard, I’ll be thankful.
August 3, 2005 at 8:44 pm
Hi neo,
U r problem sounds like u are not using the username and password. in urcode.
if u post the connection code then it will be much better.
from
killer
August 4, 2005 at 12:11 am
hi killer,
following is code which i am using to connect to database
plz help me in this regard.
************CODE START*****************
Imports
System.Data
Imports
System.Data.SqlClient
Public
Class conTest
Inherits System.Web.UI.Page
#
Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent()
Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection
'
'SqlConnection1
'
Me.SqlConnection1.ConnectionString = "workstation id=clientname;packet size=4096;integrated security=SSPI;data source" & _
"=servername;persist security info=False;initial catalog=trial"
End Sub
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents lblInfo As System.Web.UI.WebControls.Label
Protected WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#
End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
SqlConnection1.Open()
lblInfo.Text = "<b>Server Version:</b> " & SqlConnection1.ServerVersion
lblInfo.Text &= "<br><b>Connection Is:</b> " & SqlConnection1.State.ToString()
SqlConnection1.Close()
lblInfo.Text &= "<br><b>Now Connection Is:</b> "
lblInfo.Text &= SqlConnection1.State.ToString()
End Sub
End
Class
***********CODE END***********************
thnx
neoms21
August 4, 2005 at 1:15 am
hi neo,
Me.SqlConnection1.ConnectionString = "workstation id=clientname;packet size=4096;integrated security=SSPI;data source" & _
"=servername;persist security info=False;initial catalog=trial"
End Sub
in ur sqlconnection string u should also define the username by which u want to connet to sql and its password.
ex: username =sa, password=simfol
hope this help u
from
killer
August 4, 2005 at 7:51 am
Hi all,
As you know, there are two types of authentication on SQL Server (the same for MSDE): Mixed(user and windows) and Windows only.
Only when you use User authentication you have to explicitlly pass in the ConnectionString User=an user , Password=your password and you have to remove "integrated security=SSPI" from ConnectionString.
I suppose that your problem is when you fill the data source or initial catalog keywords.
First of all, make sure that "trial" is the name of an existing database on the server you are trying to connect.
Second, but more important is the name of the "data source"
For example, if the coresponding service of your SQL Server installation is MSSQLServer then the data source must be the NetBios name of the computer where SQL Server installation resides. If the coresponding service of your SQL Server installation is like MSSQL$ then the data source must be \, where is the NetBios name of the computer where SQL Server is installed.
Good luck,
BAM
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply