string str="Data Source=localhost;User ID=sa;Password=aa2;Initial Catalog=test;Initial Catalog是你要访问的那个表名
解决方案 »
- C#操作Excel命名單元格
- GridView用编程方法添加“编辑”,单击后没有切换到“编辑”状态。
- 删除时碰到外键的问题,解决不了,请大家帮忙!!
- SQL2000查询结果保存为XML文件时的一个细节?
- asp.net 一个初级问题!郁闷中...
- 选择m-n条记录的sql语句怎么写?
- 高手们,高分悬赏!!!都进来讨论asp.net动态网页postback的“闪烁”问题!!!
- 树型DropdownList
- 求教一个水晶报表的问题!
- 关于input非服务器控件checkbox的问题,折磨死我了,求大神解答!
- 关于windows 2003下不能创建项目?
- 求,.net数据库连接池代码和原理文章,谢谢!
还有,可以不指定database,直接指定表吗?
try it 睡觉去了~^_^
太有郁闷了。
{
Console.write (e.ToString());}
看看具体的问题!
-------------
注:这次我用的是sqladapter的向导生成的connect string
连接串完全正确,是最简单的连接串写法.
我一向也这样写的至于为什么在 web application 上出现这个问题. 就真的很奇怪了.
catch(SqlException ex) 看看 ex 是什么?
借楼主的地方问一下:
xp下安装sql server个人版,可以远程连接么?
反正iis在xp下限制5个连接,sql就不知道了。
SQL服务器->右键->属性配置->安全性->身份验证:选WINDOWS和SQL SERVER
----------------------
不可能是这个问题,不然用vs.net是连不上的,用console也不会连上。
string str="Data Source=localhost;User ID=sa;Password=aa2;Initial Catalog=test;"test一定是数据库名哈哈不好意思搞错了
test是数据库名^_^
上次SQL server 服务器升级,然后我的web就连不上了。
后来我们的DBA不只怎么设置了一下,就好了。
所以是SQL server的问题我的贴子:
http://expert.csdn.net/Expert/topic/2869/2869525.xml?temp=.1514093
个人认为问题还没解决。
紧紧跟紧,关注无限!!!
<%@ Import namespace = "System.Data.SqlClient"%>
<%@ Page Language="C#" Debug="true" %>
<html>
<head>
<title>DataReader</title>
</head>
<body>
<h1>DataReader</h1>
Total Products listed =
<asp:DataGrid id ="dgCount" runat = "server"
BorderWidth = "0" ShowHeader="False"/>
<br/>
<asp:DataGrid id = "dgData" runat = "server"/>
</body>
</html><script language = "c#" runat = "server">
private void Page_Load(object sender, System.EventArgs e)
{
String strConnection = "server = local;database = Northwind;integrated security = true";
SqlConnection objConnection = new SqlConnection(strConnection);
objConnection.Open();
String strSQLcount;
strSQLcount = "SELECT COUNT(ProductName)FROM[Product Sales for 1997]";
SqlCommand objCommand = new SqlCommand(strSQLcount,objConnection);
SqlDataReader objReader = objCommand.ExecuteReader(); dgCount.DataSource = objReader;
dgCount.DataBind();
objReader.Close();
String strProcName;
strProcName = "SELECT * FROM [Product Sales for 1997]";
objCommand.CommandText = strProcName;
objReader = objCommand.ExecuteReader(); dgData.DataSource = objReader;
dgData.DataBind();
objConnection.Close();
}
</script>
我这也是连不上sql server,????
<%@import Namespace="System.SqlClient"%>
<script runat="server" language="c#">
void Page_Load()
{
string con="server=172.18.192.33;uid=sa;pwd=;database=xxkweb;";
SqlClientConnection objConnection=new SqlClientConnection(con);
SqlClientCommand objCommand1 = new SqlClientCommand("select * from users",objConnection);
objConnection.Open();
dgrdMain.DataSource=objCommand1.ExecuteReader();//dgrdMain就是下面的DATAGRID的ID
dgrdMain.DataBind();
objConnection.Close();
}
</script>
<html>
<body>
<asp:DataGrid id="dgrdMain" cellpadding="1" showheader="true" borderwidth="0" runat="server" />
</body>
</html>
我的也是,连出错信息都没有,只有什么叫我把errormessage的mode设为off的页面,连教程里的.aspx都不能运行,出错界面一样。帮我一下瓦