haiboss
25-05-2009, 15:58
đoạn code như sau viết trên destop chay được nhưng web báo lỗi:
Command = New SqlCommand()
Command.Connection = cnn
Command.CommandText = SQL
Command.CommandType = CommandType.StoredProcedure
If TryToConnect() = True Then
DataAdapter = New SqlDataAdapter
DataAdapter.SelectCommand = Command
ds = New DataSet
DataAdapter.Fill(ds, "test") <-- day nè
If ds.Tables(0).Rows.Count > 0 Then
Return ds.Tables(0).Rows.Count
Else
Return SQL
End If 'ds
End If
error : SelectCommand.Connection property has not been initialized.
chuoi connectstring :
Data Source=10.56.4.34,5050;Network Library=DBMSSOCN;Initial Catalog=Northwind;User ID=sa;Password="";
chuổi connectstring nằm trong file web.config
<appSettings>
<add key="conn" value="Data Source=10.56.4.34,5050;Network Library=DBMSSOCN;Initial Catalog=Northwind;User ID=sa;Password="";"/>
</appSettings>
<connectionStrings>
<add name="conn" connectionString="Data Source=10.56.4.34,5050;Network Library=DBMSSOCN;Initial Catalog=Northwind;User ID=sa;Password="";" providerName="System.Data.SqlClient"/>
</connectionStrings>
có anh chị nào bị lổi này chỉ e khắc phục.e xin Cảm ơn
Command = New SqlCommand()
Command.Connection = cnn
Command.CommandText = SQL
Command.CommandType = CommandType.StoredProcedure
If TryToConnect() = True Then
DataAdapter = New SqlDataAdapter
DataAdapter.SelectCommand = Command
ds = New DataSet
DataAdapter.Fill(ds, "test") <-- day nè
If ds.Tables(0).Rows.Count > 0 Then
Return ds.Tables(0).Rows.Count
Else
Return SQL
End If 'ds
End If
error : SelectCommand.Connection property has not been initialized.
chuoi connectstring :
Data Source=10.56.4.34,5050;Network Library=DBMSSOCN;Initial Catalog=Northwind;User ID=sa;Password="";
chuổi connectstring nằm trong file web.config
<appSettings>
<add key="conn" value="Data Source=10.56.4.34,5050;Network Library=DBMSSOCN;Initial Catalog=Northwind;User ID=sa;Password="";"/>
</appSettings>
<connectionStrings>
<add name="conn" connectionString="Data Source=10.56.4.34,5050;Network Library=DBMSSOCN;Initial Catalog=Northwind;User ID=sa;Password="";" providerName="System.Data.SqlClient"/>
</connectionStrings>
có anh chị nào bị lổi này chỉ e khắc phục.e xin Cảm ơn