<%@ Import Namespace="System.Data.SqlClient" %>
<script language="c#" runat="server">
void Page_Load()
{
string strConnection,strSQL;
strConnection = "user id=sa;password=;";
strConnection += "initial catalog=northwind;data source=LUMIAN\\ETHAN";
strConnection += "Connect Timeout=30";
strSQL = "SELECT CompanyName,ContactName FROM Suppliers";
SqlConnection objConnection = new SqlConnection(strSQL);
DataSet objDataSet = new DataSet();
SqlDataAdapter objDataAdapter = new SqlDataAdapter(strSQL,objConnection);
objDataAdapter.Fill(objDataSet,"Suppliers");
DataView objDataView = new DataView(objDataSet.Tables["Suppliers"]);
dgSuppliers.DataSource = objDataView;
dgSuppliers.DataBind();
}
</script>
<html>
<body>
<asp:DataGrid id="dgSuppliers" runat="server" />
</body>
</html>
出现错误:
Exception Details: System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
请问这是怎么回事啊???
8 个解决方案
#1
strConnection = "user id=sa;password=;";
strConnection += "initial catalog=northwind;data source=LUMIAN\\ETHAN";
strConnection += "Connect Timeout=30";
--------------------
应该是连接字符串有问题,所以在初始化数据库连接时抛出字符串格式不对
试试:
----------------------------
strConnection = "user id=sa;password=;";//不知道password这样写有没有问题
strConnection += "initial catalog=northwind;data source=LUMIAN\\ETHAN;";
strConnection += "Connect Timeout=30";
strConnection += "initial catalog=northwind;data source=LUMIAN\\ETHAN";
strConnection += "Connect Timeout=30";
--------------------
应该是连接字符串有问题,所以在初始化数据库连接时抛出字符串格式不对
试试:
----------------------------
strConnection = "user id=sa;password=;";//不知道password这样写有没有问题
strConnection += "initial catalog=northwind;data source=LUMIAN\\ETHAN;";
strConnection += "Connect Timeout=30";
#2
哦,学!
#3
password没有问题
而且能够连接的上
而且能够连接的上
#4
是连接字符串的问题
第二句中有问题,改了就好了
strConnection = "user id=sa;password=;";
strConnection += "initial catalog=northwind;data source=LUMIAN\\ETHAN;";
strConnection += "Connect Timeout=30";
第二句中有问题,改了就好了
strConnection = "user id=sa;password=;";
strConnection += "initial catalog=northwind;data source=LUMIAN\\ETHAN;";
strConnection += "Connect Timeout=30";
#5
啊????我发现确了个分号啊。但是我加了,还是有这个错误:
Exception Details: System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
真的!·!!
Exception Details: System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
真的!·!!
#6
strConnection = "user id=sa;password=;";
-------------------------------------------
strConnection = "user=sa;password=;";
或者
strConnection = "user=sa;";
-------------------------------------------
strConnection = "user=sa;password=;";
或者
strConnection = "user=sa;";
#7
就是连接我的没有出现问题啊
#8
完了完了,麻烦各位了,真是丢面子了,我知道了,又是打得粗心大意!
ft:我只有五分了怎么办啊?
ft:我只有五分了怎么办啊?
#1
strConnection = "user id=sa;password=;";
strConnection += "initial catalog=northwind;data source=LUMIAN\\ETHAN";
strConnection += "Connect Timeout=30";
--------------------
应该是连接字符串有问题,所以在初始化数据库连接时抛出字符串格式不对
试试:
----------------------------
strConnection = "user id=sa;password=;";//不知道password这样写有没有问题
strConnection += "initial catalog=northwind;data source=LUMIAN\\ETHAN;";
strConnection += "Connect Timeout=30";
strConnection += "initial catalog=northwind;data source=LUMIAN\\ETHAN";
strConnection += "Connect Timeout=30";
--------------------
应该是连接字符串有问题,所以在初始化数据库连接时抛出字符串格式不对
试试:
----------------------------
strConnection = "user id=sa;password=;";//不知道password这样写有没有问题
strConnection += "initial catalog=northwind;data source=LUMIAN\\ETHAN;";
strConnection += "Connect Timeout=30";
#2
哦,学!
#3
password没有问题
而且能够连接的上
而且能够连接的上
#4
是连接字符串的问题
第二句中有问题,改了就好了
strConnection = "user id=sa;password=;";
strConnection += "initial catalog=northwind;data source=LUMIAN\\ETHAN;";
strConnection += "Connect Timeout=30";
第二句中有问题,改了就好了
strConnection = "user id=sa;password=;";
strConnection += "initial catalog=northwind;data source=LUMIAN\\ETHAN;";
strConnection += "Connect Timeout=30";
#5
啊????我发现确了个分号啊。但是我加了,还是有这个错误:
Exception Details: System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
真的!·!!
Exception Details: System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
真的!·!!
#6
strConnection = "user id=sa;password=;";
-------------------------------------------
strConnection = "user=sa;password=;";
或者
strConnection = "user=sa;";
-------------------------------------------
strConnection = "user=sa;password=;";
或者
strConnection = "user=sa;";
#7
就是连接我的没有出现问题啊
#8
完了完了,麻烦各位了,真是丢面子了,我知道了,又是打得粗心大意!
ft:我只有五分了怎么办啊?
ft:我只有五分了怎么办啊?