09/10/2018, 18:19

Mới học ASP mong được giúp đỡ

Mình mới học lập trình WEB bằng ASP gặp một số lỗi sau trong việc kết nối CSDL

mong các bạn giúp đỡ
Mình đã tạo một DSN trong Data Sources tên là "pub"
sau đó mình tạo kết nối đến bằng câu lệnh :

Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open "DSN=pub"

Đầu tiên nó ra hộp thoại thông báo

JIT Debugging component registration is incorrect
Please repair the installation of the most recent version of Visual Studio .NET

or Remote Debugging components
Alternatively, excute the following command as an Administrator to manually

repair the JIT Debugging component registration :
"C:Program FilesCommon FilesMicrosoft SharedVS7debugvs7jit.exe"/RegServer

(Mình vừa cài VS .NET vừa cài VS 6.0 trên Win XP)

Sau đó nó ra trang html thông báo lỗi nội dung chính như sau
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E4D)
[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user

'USRNAMEIUSR_USRNAME'.
/learn/ASP/example1.asp, line 23
(dòng 23 là : myConn.Open "DSN=pub")


Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)

Page:
GET /learn/ASP/example1.asp
xacuop viết 20:31 ngày 09/10/2018
dùng DSN ko được thì dùng ConnectionString đi bạn.
VD: kết nối tới access:
Set conn=Server.CreateObject("ADODB.Connection")
strconn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=c:\path\data.mdb"
conn.Open strconn
traiHanoi viết 20:29 ngày 09/10/2018
bạn thử dùng Jet xem
có lẽ nhanh hơn đấy
set objConn = Server.CreateObject("AĐOB.connection")
strConn = "provider=Microsoft.Jet.OLEDB.4.0 ; data source=duongdanCSDL"
objConn.open strConn
ninjaru viết 20:23 ngày 09/10/2018
Cám ơn Xacuop, tui thử rồi dùng ConnectionString thì OK nhưng ko hiểu sao dùng DSN lại ko được.
QueenRock viết 20:23 ngày 09/10/2018
Bạn phải vào control panel / administrator tools / Data sources ... gì gì đó ... tạo DSN rồi mới connect vào được
xacuop viết 20:32 ngày 09/10/2018
ko cần đâu QueenRock, chỉ cần file dsn là được. Nhưng lâu quá ko làm nên xacuop ko nhơ rõ để debug đành chỉ qua connection string
Bài liên quan
0