I keep getting the following error.
I seem to have tried everything, heres the stack trace:-
[SqlException: SQL Server does not exist or access
denied.]
System.Data.SqlClient.SqlConnection.Open() +759
ConnectionTest1.WebForm1.Page_Load(Object sender,
EventArgs e) in c:\inetpub\wwwroot\ConnectionTest1
\WebForm1.aspx.vb:35
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +29
System.Web.UI.Page.ProcessRequestMain() +724
I've pinged the server and it's there!
I can connect through access, I have ASP pages running
off SQL db's on the server.
I am close to the edge :o
Here's the code I'm running, can anyone help me or walk
me through getting connected pleeeeze.
also any test code would be appreciated:
CODE:
Imports System.Data.SqlClient

Public Class WebForm1
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()

End Sub

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
Dim strConnection As New SqlConnection
("Password=;" & _
"Persist
Security Info=True;" & _
"User ID=sa;"
& _
"Initial
Catalog=pubs;" & _
"Data
Source=myDatabase")


Dim strSql As String = "SELECT * FROM authors"


Dim objCmd As New SqlClient.SqlCommand(strSql,
strConnection)
strConnection.Open()
'objCmd.ExecuteNonQuery()
strConnection.Close()
End Sub

End Class
Thanks in advance

Re: cannot connect to SQLServer! by Steve

Steve
Tue Jul 29 04:18:58 CDT 2003

Thanks for reply,
I just used myDatabase for security,
the SQL server is held on our webserver and has the same
name eg steveserver = webserver name
steveserver = instance of sql server
>-----Original Message-----
>Steve,
>
>What's the name of your SQL Server, is it myDatabase? If
not, that might be
>your answer.
>
>--
>Carsten Thomsen
>Enterprise Development with Visual Studio .NET, UML, and
MSF
>http://www.apress.com/book/bookDisplay.html?bID=105
>"steve" <steven.chambers@threerivers.gov.uk> wrote in
message
>news:01bd01c35522$9ea1d1c0$a101280a@phx.gbl...
>> I keep getting the following error.
>> I seem to have tried everything, heres the stack
trace:-
>> [SqlException: SQL Server does not exist or access
>> denied.]
>> System.Data.SqlClient.SqlConnection.Open() +759
>> ConnectionTest1.WebForm1.Page_Load(Object sender,
>> EventArgs e) in c:\inetpub\wwwroot\ConnectionTest1
>> \WebForm1.aspx.vb:35
>> System.Web.UI.Control.OnLoad(EventArgs e) +67
>> System.Web.UI.Control.LoadRecursive() +29
>> System.Web.UI.Page.ProcessRequestMain() +724
>> I've pinged the server and it's there!
>> I can connect through access, I have ASP pages running
>> off SQL db's on the server.
>> I am close to the edge :o
>> Here's the code I'm running, can anyone help me or walk
>> me through getting connected pleeeeze.
>> also any test code would be appreciated:
>> CODE:
>> Imports System.Data.SqlClient
>>
>> Public Class WebForm1
>> 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()
>>
>> End Sub
>>
>> 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
>> Dim strConnection As New SqlConnection
>> ("Password=;" & _
>> "Persist
>> Security Info=True;" & _
>> "User
ID=sa;"
>> & _
>> "Initial
>> Catalog=pubs;" & _
>> "Data
>> Source=myDatabase")
>>
>>
>> Dim strSql As String = "SELECT * FROM authors"
>>
>>
>> Dim objCmd As New SqlClient.SqlCommand(strSql,
>> strConnection)
>> strConnection.Open()
>> 'objCmd.ExecuteNonQuery()
>> strConnection.Close()
>> End Sub
>>
>> End Class
>> Thanks in advance
>
>
>.
>

Re: cannot connect to SQLServer! by Blore

Blore
Tue Jul 29 10:20:02 CDT 2003

Try this out

Dim sqlCnn as New SQLConnection("server=localhost;initial
catalog = pubs;uid=sa;pwd=;")

sqlCnn.Open

put in your server name nand userid password for the sql
server. it works just fine for me

>-----Original Message-----
>Thanks for reply,
>I just used myDatabase for security,
>the SQL server is held on our webserver and has the same
>name eg steveserver = webserver name
> steveserver = instance of sql server
>>-----Original Message-----
>>Steve,
>>
>>What's the name of your SQL Server, is it myDatabase? If
>not, that might be
>>your answer.
>>
>>--
>>Carsten Thomsen
>>Enterprise Development with Visual Studio .NET, UML, and
>MSF
>>http://www.apress.com/book/bookDisplay.html?bID=105
>>"steve" <steven.chambers@threerivers.gov.uk> wrote in
>message
>>news:01bd01c35522$9ea1d1c0$a101280a@phx.gbl...
>>> I keep getting the following error.
>>> I seem to have tried everything, heres the stack
>trace:-
>>> [SqlException: SQL Server does not exist or access
>>> denied.]
>>> System.Data.SqlClient.SqlConnection.Open() +759
>>> ConnectionTest1.WebForm1.Page_Load(Object sender,
>>> EventArgs e) in c:\inetpub\wwwroot\ConnectionTest1
>>> \WebForm1.aspx.vb:35
>>> System.Web.UI.Control.OnLoad(EventArgs e) +67
>>> System.Web.UI.Control.LoadRecursive() +29
>>> System.Web.UI.Page.ProcessRequestMain() +724
>>> I've pinged the server and it's there!
>>> I can connect through access, I have ASP pages running
>>> off SQL db's on the server.
>>> I am close to the edge :o
>>> Here's the code I'm running, can anyone help me or walk
>>> me through getting connected pleeeeze.
>>> also any test code would be appreciated:
>>> CODE:
>>> Imports System.Data.SqlClient
>>>
>>> Public Class WebForm1
>>> 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()
>>>
>>> End Sub
>>>
>>> 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
>>> Dim strConnection As New SqlConnection
>>> ("Password=;" & _
>>> "Persist
>>> Security Info=True;" & _
>>> "User
>ID=sa;"
>>> & _
>>> "Initial
>>> Catalog=pubs;" & _
>>> "Data
>>> Source=myDatabase")
>>>
>>>
>>> Dim strSql As String = "SELECT * FROM authors"
>>>
>>>
>>> Dim objCmd As New SqlClient.SqlCommand(strSql,
>>> strConnection)
>>> strConnection.Open()
>>> 'objCmd.ExecuteNonQuery()
>>> strConnection.Close()
>>> End Sub
>>>
>>> End Class
>>> Thanks in advance
>>
>>
>>.
>>
>.
>