.net与sql 2000数据库连接的具体方法

zqj2001120 2005-11-17 09:44:26
我是.net的初学者,请教各位如何连接sql 2000数据库。需要注意些什么?有这方面的教程不?
...全文
177 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
zqj2001120 2005-11-21
  • 打赏
  • 举报
回复
谢谢各位。
hoowoo 2005-11-21
  • 打赏
  • 举报
回复
我写的一篇技术文章.希望你看一下!!
http://dev.yesky.com/msdn/248/2164248.shtml
上面有消息的步骤和原理
pearsonlang 2005-11-17
  • 打赏
  • 举报
回复
我运行framework sdk下面的例子,其他正常,安装了MDAC_TYP.EXE,MSDE2000A.exe,netframework1.1.exe。但连接数据库时出现以下
Exception Details: System.Data.SqlClient.SqlException: SQL Server does not exist or access denied.
Source Error:

The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:

1. Add a "Debug=true" directive at the top of the file that generated the error. Example:

<%@ Page Language="C#" Debug="true" %>

or:

2) Add the following section to the configuration file of your application:

<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>

Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.

Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.
zqj2001120 2005-11-17
  • 打赏
  • 举报
回复
谢谢各位帮助,我是用VB语言的,上面的都可以用吗?哪个效率高些????
jxufewbt 2005-11-17
  • 打赏
  • 举报
回复
SqlConnection conn=new SqlConnection("server=localhost;uid=sa;pws=sa;database=pubs");
这一句就是连接sql 2000数据库的,首先要生成一个Connection对象,这里用的是SqlConnection,在System.Data.SqlClient名字空间中,后面的参数你应该看得懂吧?书上讲的很详细,我就不多说了。
shixianyong 2005-11-17
  • 打赏
  • 举报
回复
"Data Source=Aron1;Initial Catalog=pubs;User Id=sa;Password=asdasd;"
- or -
"Server=Aron1;Database=pubs;User ID=sa;Password=asdasd;Trusted_Connection=False"

C#:
using System.Data.SqlClient;
SqlConnection oSQLConn = new SqlConnection();
oSQLConn.ConnectionString="my connectionstring";
oSQLConn.Open();

VB.NET:
Imports System.Data.SqlClient
Dim oSQLConn As SqlConnection = New SqlConnection()
oSQLConn.ConnectionString="my connectionstring"
oSQLConn.Open()
hexinyu2005 2005-11-17
  • 打赏
  • 举报
回复
慢了一步
hexinyu2005 2005-11-17
  • 打赏
  • 举报
回复
SqlConnection conn=new SqlConnection();
conn.ConnectionString="data source=hxyu;initial catalog=Test;user id=sa;password=a";
SqlCommand comm=null;
SqlDataReader reader=null;
comm=new SqlCommand();
comm.CommandText=cmdString;
comm.Connection=conn;
reader=comm.ExecuteReader();
return reader;
jxufewbt 2005-11-17
  • 打赏
  • 举报
回复
示例:
public void UpdateNewsClicked(string ID)
{
try
{
SqlConnection conn=new SqlConnection("server=localhost;uid=sa;pws=sa;database=pubs");
string text=" Update News set Clicked=Clicked+1 where ID="+ID;
SqlCommand command=new SqlCommand(text,conn);
conn.Open();
command.ExecuteNonQuery();
conn.Close();
}
catch(Exception ex)
{
Response.Write("<script language='javascript'>alert("+ex.Message+");</script>");
}
}

17,748

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 .NET Framework
社区管理员
  • .NET Framework社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧