PDA

View Full Version : asp.NET thắc mắc tập 2



QueenRock
19-09-2004, 23:14
tôi mới cài lại máy, cài Microsoft .NET Framework Version:1.1 (dotnetfx.exe) xong xuôi, khi khai báo SQLCommand thì gặp thông báo như thế này :huh:

Compiler Error Message: BC30002: Type 'SQLCommand' is not defined.

Lần trước cài xong thì OK, lần này lại bị như vậy, không hiểu sao nữa. Mong các bác chỉ bảo, thanks :)

linhnhan
20-09-2004, 02:32
Coi lại việc ref đến mấy cái Namespace về database.
Ví dụ:
<%@ Import Namespace="System.data.ADO" %>
<%@ import Namespace="System.Data.SQL" %>
<%@ import Namespace="System.Data.SqlClient" %>
<%Import Namespace="System.Data.SqlTypes" %>

White Rose
20-09-2004, 06:22
What's your language?
If C#, C++.NET or J#, the correct word is "SqlCommand", not "SQLCommand"

QueenRock
20-09-2004, 07:42
a có khai báo nhưng nó không tìm thấy System.Data.SQL

Cận
20-09-2004, 10:31
The correct namespace is System.Data.SqlClient

QueenRock
20-09-2004, 10:47
Được rồi, cảm ơn bác Cận nhiều
Tiện thể cho tớ hỏi luôn, trong C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322 của tớ không có file này, nhưng sao import vào vẫn được nhỉ (he he đừng ai cười nhé)

Cận
20-09-2004, 23:40
cái file đó là file system.data.dll đó, không phải là file system.data.sqlclient.dll đâu lol

traiHanoi
19-10-2004, 16:57
alo Cận
Cho hỏi lỗi này với

Login failed for user 'nam'. Reason: Not associated with a trusted SQL Server connection.

user 'nam' đã có
báo lỗi ở dòng có dấu *

Sub Page_Load(Source As Object, E As EventArgs)
Dim myCommand as SQLCommand
Dim myConn As SQLConnection
Dim myReader As SQLDataReader
Dim SQL as String
Dim connStr as String
connStr="data source=localhost; initial catalog=testIQ; User ID=nam; Password=;"
SQL="select * from tbl_Des"
myConn = new SQLConnection(connStr)
myCommand = new SQlCommand(SQL,myConn)
*myConn.Open()
myReader=myCommand.ExecuteReader()

while myReader.Read()
HoTen.Items.add(new ListItem(trim(myReader.Item("desid")), myReader.Item("id")))
end while
end Sub

nguoikicuc
20-11-2004, 02:59
"Login failed for user 'nam'. Reason: Not associated with a trusted SQL Server connection." <-- Look like SQL Server mode set to Windows authentication. Trong mode nay thi` ba.n khong duoc supply username/password, mà SQL Server sẽ tự động check Windows login của bạn (thật ra là login của cái process mà bạn đang run)

Trong mode kia, SQL Server authentication, the server sẽ check login của bạn voi SQL Server accounts, và bạn phải supply username/password.