200分就解决System.Data.SqlClient.SqlException: SQL Server 不存在或访问被拒绝。

com_gao 2003-09-03 08:44:45
System.Data.SqlClient.SqlException: SQL Server 不存在或访问被拒绝。

2003-09-03 08:03:08 com_gao(52022920)
有谁了解sql....我很郁闷。
所有连接sql的操作都不成功!!!
winserver2000...+sqlserver2000...+iis5...
+vs.net...
我使用.net(中文)自带的例子都通不过。说找不到sql服务器...有没有人遇到过类似的。我第一接触mssqlserver2000...的编程

2003-09-03 08:04:05 DemonHunter(76763831)
sql服务打开没?

2003-09-03 08:04:16 com_gao(52022920)
打开了

2003-09-03 08:04:52 DemonHunter(76763831)
用服务管理器刷新一下

2003-09-03 08:05:28 com_gao(52022920)
Microsoft .NET Framework SDK 快速入门、教程和示例

这里的例子,你也装了吧,与数据库的操作就不通过

2003-09-03 08:05:57 DemonHunter(76763831)
我看看

2003-09-03 08:07:08 DemonHunter(76763831)
找不到~~~

2003-09-03 08:07:41 com_gao(52022920)
你装了.net环境了没有

2003-09-03 08:08:04 DemonHunter(76763831)

我说找不到数据库操作的例子

2003-09-03 08:08:18 com_gao(52022920)
就在asp.net快速入门

2003-09-03 08:08:35 com_gao(52022920)
然后找 ASP.NET Web 窗体

2003-09-03 08:08:47 DemonHunter(76763831)
ok

2003-09-03 08:09:04 com_gao(52022920)
服务器端数据访问
目录里,随便找个例子运行一下

2003-09-03 08:10:13 DemonHunter(76763831)
我的可以啊

2003-09-03 08:10:30 com_gao(52022920)
阿?我的数据库的问题????

2003-09-03 08:10:51 DemonHunter(76763831)
应该是吧

2003-09-03 08:10:51 com_gao(52022920)
http://localhost/quickstart/aspplus/samples/webforms/customize/VB/datalist1.aspx
你打这个例子

2003-09-03 08:11:20 com_gao(52022920)
错误是:[SqlException: SQL Server 不存在或访问被拒绝。]


2003-09-03 08:11:52 DemonHunter(76763831)
我的可以显示那个藏书室

2003-09-03 08:12:42 com_gao(52022920)
你的sql设密码了没?

2003-09-03 08:12:47 DemonHunter(76763831)


2003-09-03 08:13:06 com_gao(52022920)
你的sql默认的用户是sa把?

2003-09-03 08:13:11 DemonHunter(76763831)


2003-09-03 08:13:51 com_gao(52022920)
你安装的时候选择的是用系统用户登录还是sql和系统混和登录

2003-09-03 08:14:09 DemonHunter(76763831)
后者

2003-09-03 08:14:20 com_gao(52022920)
我也是阿

2003-09-03 08:14:27 DemonHunter(76763831)
y ....

2003-09-03 08:14:42 DemonHunter(76763831)
你有权限没?

2003-09-03 08:14:52 com_gao(52022920)
问题在那???????


我用的是administrator..

2003-09-03 08:14:59 com_gao(52022920)
登录

2003-09-03 08:15:32 DemonHunter(76763831)
不懂~
...全文
182 点赞 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
wdczzh 2003-09-07
我建议你先用管理工具中的ODBC数据源管理器建立一个”数据源“测试看看能否连通SQLSERVER,如连不通的话,检查SQLSERVR是否已正常启动、1433端口打开没有;如果连通了,那你就要好好检查一下程序了。
回复
nboys 2003-09-03
给你一个例子:

GroupsDlist.vb

Option Strict Off
Imports System
Imports System.Collections
Imports System.Text
Imports System.Data
Imports System.Data.OleDb
Imports System.Web.UI
Imports System.Web.UI.WebControls
Public Class BaseClass
Inherits System.Web.UI.Page
protected Grid1 as Datalist
Protected Message as label
Dim myConnection As OleDbConnection
Dim myCommand As OleDbDataAdapter
Dim ds As New DataSet
Dim ConnStr As String
Dim SQL As String
Sub Page_Load(Source As Object, E As EventArgs)
ConnStr = "Provider=SQLOLEDB; Data Source=(local); Initial Catalog=ASPNET;User ID=sa;PWD=pwd"
myConnection = New OleDbConnection(ConnStr)
if NOT (isPostBack)
rebind
end if
End Sub
Sub ReBind()
'DataSetCommand
SQL = "select * from Groups"
myCommand = New OleDbDataAdapter(SQL, myConnection)
'use Fill method of DataSetCommand to populate dataset
myCommand.Fill(ds, "Groups")
'Binding a Grid
Grid1.DataSource=ds.Tables("Groups").DefaultView
Grid1.DataBind()
end sub
Sub DataList_EditCommand(sender As Object, e As DataListCommandEventArgs)
Grid1.EditItemIndex = e.Item.ItemIndex
rebind
End Sub
Sub DataList_CancelCommand(sender As Object, e As DataListCommandEventArgs)
Grid1.EditItemIndex = -1
rebind
End Sub
End Class



GroupsDlist.aspx
<%@Page Language="VB" Inherits="BaseClass" Src="GroupsDlist.vb" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<html>
<script language="VB" runat="server">
Sub DataList_UpdateCommand(sender As Object, e As DataListCommandEventArgs)
dim sql as string
Dim code_display As String
Dim type As String
Dim myTextBox As TextBox
myTextBox = E.Item.FindControl("edit_display")
code_display = mytextbox.text
myTextBox = E.Item.FindControl("edit_type")
type = mytextbox.text
'Now execute stored procedure
response.write("Execute some procedure @name=" + code_display + "@type=" + type)
End Sub
</script>
<body style="font: 10pt verdana">
<form runat="server">
<h3><font face="Verdana">Groups (DataList) </font></h3>
<asp:Label id="Message" runat="server"/>
<asp:DataList id="Grid1" runat="server"
BorderColor="black"
BorderWidth="1"
GridLines="Both"
CellPadding="3"
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
Width="800px"
HeaderStyle-BackColor="#aaaadd"
AlternatingItemStyle-BackColor="Gainsboro"
EditItemStyle-BackColor="lightgreen"
OnEditCommand="DataList_EditCommand"
OnUpdateCommand="DataList_UpdateCommand"
OnCancelCommand="DataList_CancelCommand"
RepeatColumns="3" RepeatDirection="horizontal" RepeatMode="Table" >
<HeaderTemplate>Name</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton id="button1" runat="server" Text="Edit" CommandName="edit" />
<%# Container.DataItem("code_display") %>
</ItemTemplate>
<EditItemTemplate>
Name:
<asp:Label id="Label1" runat="server" Text='<%# Container.DataItem("code_display") %>' />
<br>
Group:
<asp:TextBox id="edit_display" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "code_display") %>' />
<br>
Type:
<asp:TextBox id="edit_type" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "type") %>' />
<br>
<asp:LinkButton id="button2" runat="server" Text="Update" CommandName="update" />
<asp:LinkButton id="button3" runat="server" Text="Cancel" CommandName="cancel" />
</EditItemTemplate>
</asp:DataList>
</form>
</body>
</html>
回复
nboys 2003-09-03
Imports System.Data
imports system.io
Imports System.Data.sqlclient
imports system.web.ui
imports system.web.ui.webcontrols
imports system.text
imports system.data.oledb
imports system.collections
imports system

public class baseclass
inherits system.web.ui.page
protected datagrid1 as datagrid
dim myconn as sqlconnection
dim connstring as string
public sortfield as string
dim mysql as string
dim mycomm as sqldataadapter
dim myds as new Dataset
dim sql as string
dim ds as new dataset
Sub Page_Load(Source As Object, E As EventArgs)
connstring="Data Source=serverName; Initial Catalog=databaseName; User ID=sa;PWD=pwd"
myconn=new sqlconnection(connstring)
if not (ispostback)
if sortfield="" then
sortfield="id"
end if
rebind
end if
end sub

sub rebind()
mysql="select * from jobs"
mycomm=new sqldataadapter(mysql,myconn)
mycomm.fill(myds,"news")
dim dv2 as dataview
dv2=myds.tables("news").defaultview
dv2.sort=sortfield
datagrid1.datasource=dv2
datagrid1.databind()
end sub
end class
回复
1。服务器是否能够PING通;
2。连接数据库的PORT号是否正确。
回复
yujohny 2003-09-03
UP
回复
pengdali 2003-09-03
企业管理器-->右键你的实例(就是那个有绿色图标的)-->属性-->安全-->改为sql与window混合

如果还不行:

sqlserver服务器-->开始菜单-->SQLserver-->服务器网络实用工具-->启用 WinSock代理-->代理地址:(sqlserver服务器IP)-->代理端口-->1433-->OK了

再用ip地址直接连
回复
相关推荐
发帖
应用实例
创建于2007-09-28

2.7w+

社区成员

MS-SQL Server 应用实例
申请成为版主
帖子事件
创建了帖子
2003-09-03 08:44
社区公告
暂无公告