Just nu i M3-nätverket
Jump to content

Vad är felet?


Karl

Recommended Posts

Jag har ett problem med att hämta en rad ur en databas

Jag vill hämnta kolumben Namn ur databasen login men det går inte. I databasen har jag 6 stycken kollumber Namn, ID, UserName, Password, Clearance, Epire

 

jag kan hämta kollumben Clearance men inte Namn vad e felet?

 

Jag loggar in med hjälp av denna fil:

 

<%@Language=VBScript%>

<%Response.Buffer = True%>

<!--#INCLUDE FILE="config.inc"-->

 

<html>

<body>

 

<%

UserName = Replace(Trim(Request.Form("username")), "'", "''")

PassWord = Replace(Trim(Request.Form("password")), "'", "''")

 

If UserName = "" OR PassWord = "" Then Response.Redirect "default.asp"

 

SQL = "Select ID, UserName, [PassWord], Clearance, ExpireDate From Login"

Set RS = MyConn.Execute(SQL)

 

While Not RS.EOF

If UserName = RS("UserName") And PassWord = RS("Password") Then

If RS("ExpireDate") > Now() Then

Session("allow") = True

Session("clearance") = RS("Clearance")

Level = RS("Clearance")

Else

Response.Redirect "utility.asp?method=expired"

End If

End If

RS.MoveNext

Wend

 

CleanUp(RS)

 

If Session("allow") = True Then

If Level = 1 Then Response.Redirect "1.asp"

If Level = 2 Then Response.Redirect "2.asp"

If Level = 3 Then Response.Redirect "3.asp"

If Level = 4 Then Response.Redirect "4.asp"

If Level = 5 Then Response.Redirect "5.asp"

If Level = 6 Then Response.Redirect "6.asp"

If Level = 7 Then Response.Redirect "7.asp"

If Level = 8 Then Response.Redirect "8.asp"

If Level = 9 Then Response.Redirect "9.asp"

If Level = 10 Then Response.Redirect "10.asp"

If Level = 11 Then Response.Redirect "11.asp"

If Level = 12 Then Response.Redirect "12.asp"

If Level = 13 Then Response.Redirect "13.asp"

If Level = 14 Then Response.Redirect "14.asp"

If Level = 15 Then Response.Redirect "15.asp"

If Level = 16 Then Response.Redirect "16.asp"

Else

Response.Redirect "default.asp"

End If

%>

 

</body>

</html>

 

 

 

Sedan ska jag i denna fil hämra uppgiften "namn" ur databasen

 

<%

'///////////////////////////////////////////////////////////////////////////////////

'connection string

 

Set MyConn=Server.CreateObject("ADODB.Connection")

MyConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.Mappath("Login.mdb")

 

'///////////////////////////////////////////////////////////////////////////////////

 

 

'///////////////////////////////////////////////////////////////////////////////////

'cleanup routines

 

Sub CleanUp(RS)

RS.Close

MyConn.Close

Set RS = Nothing

Set MyConn = Nothing

End Sub

 

Sub CleanUp2()

MyConn.Close

Set MyConn = Nothing

End Sub

 

'////////////////////////////////////////////////////////////////////////////////////

%>

<html>

<head>

<title>Untitled Document</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

 

<body link="#000000" text="#000000" background="red.gif" vlink="#000000" alink="#000000">

<div align="center">

<p>&nbsp;</p>

<p>&nbsp;</p>

</div>

<table width="755" border="0" height="536" align="center" cellspacing="0" cellpadding="0">

<tr>

<td height="2" bgcolor="#999999" width="151">

<div align="center"><font face="Geneva, Arial, Helvetica, san-serif" size="1">

</font></div>

</td>

<td height="2" bgcolor="#999999" width="604"><font face="Geneva, Arial, Helvetica, san-serif" size="1" color="#999999">:::::::::::</font><font face="Geneva, Arial, Helvetica, san-serif" size="1">::

<a href="start.asp">Startsida</a> :: <a href="hus.asp">Husprislistor</a> :: <a href="pdf.asp">PDF filer</a> :: <a href="excel.asp">Excel filer</a> :: <a href="word.asp">Word filer</a> :: <a href=""utility.asp?method=abandon"">Logga ut</a> :: </font></td>

</tr>

<tr>

<td bgcolor="#FFFFFF" align="left" valign="top" width="151">

<p>&nbsp;</p>

 

<p><img src="forsgrens.gif" width="165" height="33" vspace="4" hspace="6"><br>

<img src="faluhus.gif" width="160" height="16" vspace="4" hspace="6"><br>

<font size="2" face="Verdana, Arial, Helvetica, sans-serif"> <font color="#FFFFFF">:</font>&gt;V&auml;lkommen</font></p>

</td>

<td bgcolor="#FFFFFF" align="left" valign="top" width="604">

<p>&nbsp;</p>

<p><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Prislistor

och formul&auml;r 2001 : Forsgrens Timmerhus, Faluhus</font></p>

<p><font face="Verdana, Arial, Helvetica, sans-serif" size="2">

<%

Session("Name") = "Mats"

Response.Write "V&auml;lkommen <b>" & Session("Namn") & "</b>."

%>

<br><br>

<!--#include file="site_news.inc" -->

<br><br><a href=""utility.asp?method=abandon"">Logga ut</a>

</font></p>

 

Vad är felet, snälla hjälp mig lösa det vore riktigt snällt :)

Link to comment
Share on other sites

INte kan jag se att Du hämtar "Namn" ur databasen.

Pröva det här:

 

SQL = "Select Namn, ID, UserName, [PassWord], Clearance, ExpireDate From Login"

 

 

 

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.



×
×
  • Create New...