should not need any configuration file, make sure 1. enable TCP/IP protocol in Server Network Utility and Client Network Utility2. create an account with SQL Authentication method3. try connection string like
"Server=YourServerMachineName;Database=YourDBName;UID=YourSQLLoginName;PWD=YourSQLLoginPassword;"for example, you normally can do withusing System.Data.SqlClient;SqlConnection conn = new SqlConnection("Server=localhost;Database=pubs;UID=sa;PWD=;");
if your web server is on the same machine as the SQL Server 2000, and you still have the default sa accountGood luck!
"Server=YourServerMachineName;Database=YourDBName;UID=YourSQLLoginName;PWD=YourSQLLoginPassword;"for example, you normally can do withusing System.Data.SqlClient;SqlConnection conn = new SqlConnection("Server=localhost;Database=pubs;UID=sa;PWD=;");
if your web server is on the same machine as the SQL Server 2000, and you still have the default sa accountGood luck!
解决方案 »
- 关于dotmsn
- SiteMap的一个问题?顶者有分~
- 急!在线等! 同样的一个表格 在VS2003 上 height="100%" 但是在VS2005 上却显示不出高度!
- 有关TreeView的节点单击事件,如何实现?
- 根据点击动态的实现“您的位置”导航
- 为什么写入数据库的时候会出现溢出 ????????
- 哪位大虾帮忙解释一下这个现象?
- 怎样在web页面上修改远程服务器活动目录上的用户名和密码
- 如果有三个网站的数据库内容都放到一个数据库中,这样三个网站读数据库的时候会不会影响速度??
- ASP.NET中服务器控件解析问题,谢谢!
- 请问asp.net里面怎样把表单提交给下一页??
- 怎样用crystalreport的图表显示进度
<configuration>
.
.
.
<appSettings>
<add key="server1" value="initial catalog=;data source=机器名;user id=用户名;pwd=密码"/>
</appSettings>
</configuration>在代码中引用的时候就这样写:
Dim sql As String = System.Configuration.ConfigurationSettings.AppSettings("server1")
Dim cn As New System.Data.SqlClient.SqlConnection(sql)
cn.open
当然要加上Imports System.Data
Imports System.Data.SqlClient如果你想每次多自己在页面上写就按照上面那位大哥所说的那样去做吧。
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<script language="C#" runat="server">
protected void Page_Load(Object sender, EventArgs e)
{
SqlConnection myConnection=new SqlConnection
("server=(local);database=numberone; trusted_Connection=yes");
SqlDataAdapter myCommand=new SqlDataAdapter("select * from Tab_base",
myConnection);
DataSet ds =new DataSet();
myCommand.Fill(ds,"Tab_Base");
MyDataGrid.DataSource=ds.Tables["Tab_Base"].DefaultView;
MyDataGrid.DataBind();
}
</script>
<body>
<h3>清单</h3><ASP:DataGrid id="MyDataGrid" runat="server"
AutoGenerateColumns="False"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-size="8pt"
HeaderStyle-BackColor="#aaaadd"
EnableViewState="false" >
<Columns>
<asp:BoundColumn HeaderText="姓名" DataField="Tab_Name"/>
<asp:BoundColumn HeaderText="性别" DataField="Tab_Sex"/>
<asp:BoundColumn HeaderText="民族" DataField="Tab_Age"/>
</Columns>
</asp:DataGrid>
</body>
</html>
注:我的numberone数据库与aspx文件放在同一目录
错误提示:
运行时错误
说明: 服务器上出现应用程序错误。此应用程序的当前自定义错误设置禁止远程查看应用程序错误的详细信息(出于安全原因)。但可以通过在本地服务器计算机上运行的浏览器查看。 详细信息: 若要使他人能够在远程计算机上查看此特定错误信息的详细信息,请在位于当前 Web 应用程序根目录下的“web.config”配置文件中创建一个 <customErrors> 标记。然后应将此 <customErrors> 标记的“mode”属性设置为“Off”。
<!-- Web.Config 配置文件 --><configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
注释: 通过修改应用程序的 <customErrors> 配置标记的“defaultRedirect”属性,使之指向自定义错误页的 URL,可以用自定义错误页替换所看到的当前错误页。
<!-- Web.Config 配置文件 --><configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>
设置 customErrors mode="On" 或 "RemoteOnly" 以启用自定义错误信息,或设置为 "Off" 以禁用自定义错误信息。
为每个要处理的错误添加 <error> 标记。
能解释一下上面是什么意思?
<add key="conn" value="www.asp.net" />
</appSettings>当我执行时,提示如下错误:无法识别的配置节“appSettings”我已确定添加的位置是对的,如何解决啊