登录 | 注册 | FAQ
Anonymous

asp database

+ 发表回复

5 篇帖子 分页: 1 / 1


asp database

priyam » 周六 4月 13, 2013 12:50 pm

hello,
I want to connect database to my html website. I had follow asp tutorial of this site but its not working. pls help me . The code i tried is as follow

<html>
<head>
<title>Enter data into database</title>
</head>
<body>
<%

' Database connection - remember to specify path to your database

Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER = {Microsoft Access Driver (*. mdb)}; "
DSN = DSN & "DBQ=" & Server.MapPath("C:\Inetpub\wwwroot\DB1.mdb")

Conn.Open DSN

' The SQL statement is built

strSQL = "INSERT INTO Table1 ("

strSQL = strSQL & "Fname, "
strSQL = strSQL & "Lname) "



strSQL = strSQL & "VALUES("

strSQL = strSQL & "'Krishna', "

strSQL = strSQL & "'Raj')"



' The SQL statement is executed
Conn.Execute (strSQL)

' Close the database connection
Conn.Close
Set Conn = Nothing
%>

<h1>The database is updated!</h1>
</body>
</html>

最后由 priyam 编辑于 周一 4月 22, 2013 6:50 pm,总共编辑了 1 次

头像

priyam

  • 帖子: 3
  • 注册: 周二 4月 09, 2013 12:46 pm

Re: asp database

XainPro » 周一 4月 15, 2013 9:46 pm

What Error It Give it to you ?
头像

XainPro

  • 帖子: 3933
  • 注册: 周五 2月 17, 2012 8:10 pm

Re: asp database

priyam » 周一 4月 22, 2013 7:01 pm

XainPro 写道:What Error It Give it to you ?


m getting the following error: -

Error Type:
Server.MapPath(), ASP 0172 (0x80004005)
The Path parameter for the MapPath method must be a virtual path. A physical path was used.
/demo.asp, line 12


i have my site already hosted and want to provide database support to it. please help..
头像

priyam

  • 帖子: 3
  • 注册: 周二 4月 09, 2013 12:46 pm

Re: asp database

XainPro » 周二 4月 23, 2013 9:38 pm

this is complicated i would recommend you to hire a professional asp developer for this task !
头像

XainPro

  • 帖子: 3933
  • 注册: 周五 2月 17, 2012 8:10 pm

Re: asp database

phpsingh » 周一 4月 29, 2013 2:35 am

<%
response.write
(Server.MapPath("test.asp") &
"<br>")
response.write
(Server.MapPath("script/
test.asp") & "<br>")
response.write
(Server.MapPath("/script/
test.asp") & "<br>")
response.write
(Server.MapPath("\script") &
"<br>")
response.write
(Server.MapPath("/") &
"<br>")
response.write
(Server.MapPath("\") &
"<br>")
%>
Output:
c:\inetpub\wwwroot\script
\test.asp
c:\inetpub\wwwroot\script
\script\test.asp
c:\inetpub\wwwroot\script
\test.asp
c:\inetpub\wwwroot\script
c:\inetpub\wwwroot
c:\inetpub\wwwroot





yeh you now understand where you done a fatal mistake in your code.

I am too quite newbie in Asp.
头像

phpsingh

  • 帖子: 29
  • 注册: 周五 11月 09, 2012 6:08 am
--
My Passion Is Only Learning Nothing Else :)


+ 发表回复

分页: 1 / 1