테스트 사이트 - 개발 중인 베타 버전입니다

ASP SQLdb에 연결하는거 도와주세여.. 채택완료

배워볼려궁 10년 전 조회 8,359

<% 

'request로 입력받음┐

   name = request.Form("name")

   email = request.Form("email")

   Homepage = request.Form("homepage")

   title = request.Form("title")

   content = request.Form("content")

   pwd = request.Form("pwd")

 

'db를 연결┐

Set db = Server.CreateObject("ADODB.connection")

'db 열기┐

htdb.Open Server.CreateObject("ADODB.connection")

 

htdb_name = "htdb" '데이타베이스 명

htdb_id = "sa" '아이디

htdb_pass = "xxxxxxx" '패스워드

htdb_domain = "xxxxxxx" '디비 접속주소

'쿼리문 작성 (글번호)┐

SQL = "select max(num) from Board_Re"

Set rs = db.execute(sql)

'데이터가 없을경우┐ 

 If IsNull(rs("maxnum")) Then

'글번호에 1넣음┐ 

 number=1

 '있으면┐

 Else

'있는번호에 +1을해서 넣음┐

 number = rs("maxnum") +1

 End if

 

sql ="Insert into Myboard(name, email, homepage, title, pwd, num,"

sql=sql &"writeday, readnum, content)values"

sql=sql &"('"&name&"'"

sql=sql &",'" &email&"'"

sql=sql &",'" &homepage&"'"

sql=sql &",'" &title&"'"

sql=sql &",'" &pwd&"'"

sql=sql &",'" &number&"'"

sql=sql &",'" &Date()&"'"

sql=sql &",'" &readnum&"'"

sql=sql &",'" &content&"')"

'데이터베이스에 새로운내용을 입력┐

db.execute(sql)

'rs에 입력된 값 반환┐

rs.close

'db에 입력된 값 반환┐

db.close

Set rs = Nothing

Set db = Nothing

'실행이 끝나면 list.asp로 나타냄

response.redirect"list.asp"

%> 

 

 

오류뜨네여 자꾸 ㅠㅠMicrosoft VBScript 런타임 오류 오류 '800a01a8'

개체가 필요합니다.: 'htdb'

/test/write_ok.asp, 줄 13

이렇게 ㅠㅠ

댓글을 작성하려면 로그인이 필요합니다.

답변 2개

채택된 답변
+20 포인트
thisgun
10년 전

https://support.microsoft.com/ko-kr/kb/300382/ko 

 

OLEDB 연결방식입니다.

 

'db를 연결┐

Set db = Server.CreateObject("ADODB.connection")

'db 열기┐

htdb.Open Server.CreateObject("ADODB.connection")

 

htdb_name = "htdb" '데이타베이스 명

htdb_id = "sa" '아이디

htdb_pass = "xxxxxxx" '패스워드

htdb_domain = "xxxxxxx" '디비 접속주소 

 

위의 소스를 아래와 같이 고쳐보세요.

 

</span></font></p><p><font face="gulim, helvetica"><span style="font-size: 13.0799999237061px; line-height: 23.5440006256104px; background-color: rgb(255, 255, 255);"></span><span style="font-size: 13.0799999237061px; line-height: 23.5440006256104px;">'db를 연결┐</span></font></p><p><font face="gulim, helvetica"><span style="font-size: 13.0799999237061px; line-height: 23.5440006256104px;">Set db = Server.CreateObject("ADODB.connection")</span></font></p><p><font face="gulim, helvetica"><span style="font-size: 13.0799999237061px; line-height: 23.5440006256104px;"> </span></font></p><p><font face="gulim, helvetica"><span style="font-size: 13.0799999237061px; line-height: 23.5440006256104px;">htdb_name = "htdb"<span class="Apple-tab-span" style="white-space:pre">	</span>'데이타베이스 명</span></font></p><p><font face="gulim, helvetica"><span style="font-size: 13.0799999237061px; line-height: 23.5440006256104px;">htdb_id = "sa"<span class="Apple-tab-span" style="white-space:pre">		</span>'아이디</span></font></p><p><font face="gulim, helvetica"><span style="font-size: 13.0799999237061px; line-height: 23.5440006256104px;">htdb_pass = "xxxxxxx"<span class="Apple-tab-span" style="white-space:pre">	</span>'패스워드</span></font></p><p><font face="gulim, helvetica"><span style="font-size: 13.0799999237061px; line-height: 23.5440006256104px;">htdb_domain = "xxxxxxx"<span class="Apple-tab-span" style="white-space:pre">	</span>'디비 접속주소</span></font></p><p><font face="gulim, helvetica"><span style="font-size: 13.0799999237061px; line-height: 23.5440006256104px;">
</span></font></p><p><font face="gulim, helvetica"><span style="font-size: 13.0799999237061px; line-height: 23.5440006256104px;">'db 열기┐</span></font></p><p><font face="gulim, helvetica"><span style="font-size: 13.0799999237061px; line-height: 23.5440006256104px;">db.Open "PROVIDER=SQLOLEDB;DATA SOURCE=" & htdb_domain & ";UID=" & htdb_id & ";PWD=" & htdb_pass & ";DATABASE=" & htdb_name & ";"</span><span style="font-size: 13.0799999237061px; line-height: 23.5440006256104px; background-color: rgb(255, 255, 255);">
</span></font></p><p><font face="gulim, helvetica"><span style="font-size: 13.0799999237061px; line-height: 23.5440006256104px;">

로그인 후 평가할 수 있습니다

답변에 대한 댓글 3개

배워볼려궁
10년 전
오..연결방식엔 된거같은데 이젠 따른오류가생기네요..
ADODB.Recordset 오류 '800a0cc1'

요청한 이름 또는 서수에 해당하는 컬렉션에서 항목을 찾을 수 없습니다.

/test/write_ok.asp, 줄 24
t
thisgun
10년 전
alias 문제 같네요.

SQL = "select max(num) from Board_Re"

아래와 같이 고쳐보세요.

SQL = "select max(num) as maxnum from Board_Re"
배워볼려궁
10년 전
감사합니다 ㅠㅜ덕분에해결했습니다..최고

댓글을 작성하려면 로그인이 필요합니다.

P
10년 전

'db를 연결┐

Set db = Server.CreateObject("ADODB.connection")

'db 열기┐

htdb.Open Server.CreateObject("ADODB.connection")

 

db를 생성하셨는데

htdb.Open 하셨네요. db로 바꿔주세요

 

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

배워볼려궁
10년 전
Microsoft OLE DB Provider for ODBC Drivers 오류 '80004005'

[Microsoft][ODBC 드라이버 관리자] 데이터 원본 이름이 없고 기본 드라이버를 지정하지 않았습니다.

/test/write_ok.asp, 줄 14

이러케나옵니다 ㅠㅠㅠㅠㅠ

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인