Just nu i M3-nätverket
Gå till innehåll

Felkod i ASP vid anslutning av ACCESS DB


Hans Lövström

Rekommendera Poster

Hans Lövström

Har följande kod:


<%
Dim id
Dim   cnt,  username
Dim idt,  Kontaktpers, kontaktadress, Kontaktpnr, Kontaktpostadress, Kontakttelefon, Kontaktmail, Kontaktpostnr, Kontaktort
Dim Presentation, Lag1, Press1, Lag2, Press2
Dim Conn, sSQL, RS, skuld
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("funkfiler/Tavling.mdb")

tot = 0
cnt = 0

idt = Session("username") 
totalt = 0
totaltinbet = 0
bgcolor="#C0C0C0"


sSQL = "SELECT * FROM forening WHERE nyckel = " & idt & ""
Set RS = Server.CreateObject("ADODB.Recordset")
Set RS = Conn.Execute(sSQL)

Do While NOT RS.EOF
Forening    	    = RS("Forening")
Kontaktpers         = RS("Kontaktpers")
Kontakttele 	    = RS("Kontakttele")
Kontaktmail         = RS("Kontaktmail")
Kontaktadress       = RS("Kontaktadress")
Kontaktpostnr       = RS("Kontaktpostnr")
Kontaktort          = RS("Kontaktort")
Presentation        = RS("Presentation")
Lag1                = RS("Lag1")
Press1              = RS("Press1")
Lag2                = RS("Lag2")
Press2              = RS("Press2")
Loop
%>

Hela koden finns i bifogad fil

 

Får felmeddelande:

 

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'

[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.

/medlemsregister/tavling/forening.asp, line 24

forening.txt

Länk till kommentar
Dela på andra webbplatser

Antar att (databas)fältet är en sträng-datatyp och att raden för sql-frågan därför skall vara:

sSQL = "SELECT * FROM forening WHERE nyckel = '" & idt & "'"

Länk till kommentar
Dela på andra webbplatser

Hans Lövström

Nu till nästa problem

När jag ska uppdatera db så får jag följande problem

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

 

[Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.

 

/medlemsregister/tavling/spara_forening.asp, line 43

 

vet inte om det kan va problem med att jag inte har skrivrättighet i db, hoppas inte det för har bråkat med Ballou ett antal dagar om just skrivrättigheter.

Andra pinsamheten är att jag har många program som läser och skriver i en annan db, så vet inte varför allt krånglar nu

 

Koden ser ut på följande sätt

<%

Dim id, Forening, Kontaktpers, Kontakttele, Kontaktmail, Kontaktadress, Kontaktpostnr, Kontaktort, Presentation

Dim Lag1, Press1, Lag2, Press2, Lag3, Press3, Lag4, Press4, Lag5, Press5, Lag6, Press6, Lag7, Press7, Lag8, Press8

Dim cnt

Dim idt, Kontaktperson, Kontaktpostadress, Kontakttelefon

Dim Conn, sSQL, RS, idt2

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

Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("funkfiler/Tavling.mdb")

 

idt2 = Session("username")

 

sSQL = "UPDATE forening SET " & _

"Forening='" & Request.Form("Foreningn")& "', " & _

"Kontaktpers='" & Request.Form("Kontaktpers")& "', " & _

"Kontakttele='" & Request.Form("Kontakttele")& "', " & _

"Kontaktmail='" & Request.Form("Kontaktmail")& "', " & _

"Kontaktaddress='" & Request.Form("Kontaktadress")& "', " & _

"kontaktadress='" & Request.Form("Kontaktadress")& "', " & _

"Kontaktpostnr='" & Request.Form("Kontaktpostnr")& "', " & _

"Kontaktort='" & Request.Form("Kontaktort")& "', " & _

"Presentation='" & Request.Form("Presentation")& "', " & _

"Lag1='" & Request.Form("Lag1")& "', " & _

"Press1='" & Request.Form("Press1")& "', " & _

"Lag2='" & Request.Form("Lag1")& "', " & _

"Press2='" & Request.Form("Press1")& "', " & _

"Lag3='" & Request.Form("Lag1")& "', " & _

"Press3='" & Request.Form("Press1")& "', " & _

"Lag4='" & Request.Form("Lag1")& "', " & _

"Press4='" & Request.Form("Press1")& "', " & _

"Lag5='" & Request.Form("Lag1")& "', " & _

"Press5='" & Request.Form("Press1")& "', " & _

"Lag6='" & Request.Form("Lag1")& "', " & _

"Press6='" & Request.Form("Press1")& "', " & _

"Lag7='" & Request.Form("Lag1")& "', " & _

"Press7='" & Request.Form("Press1")& "', " & _

"Lag8='" & Request.Form("Lag1")& "', " & _

"Press8='" & Request.Form("Press1")& "', "

 

 

 

sSQL = sSQL & "WHERE nyckel = '" & idt2 & "'"

Server.CreateObject("ADODB.Recordset")

43----------> Conn.Execute(sSQL)

RS.Close

Set RS = Nothing

Conn.Close

 

Response.Redirect "index.asp"

 

Set Conn = Nothing

 

%>

Länk till kommentar
Dela på andra webbplatser

Det skall inte vara något kommatecken innan WHERE, ändra till:

"Press8='" & Request.Form("Press1")& "' " 

Länk till kommentar
Dela på andra webbplatser

Hans Lövström

Tack, det hjälpte en liten bit.

Nu gar jag kopierat från kod som fungerar i ett annat program jag har, men men får då följande fel, såhär betedde sig aldric Cobol och Fortran på den gamla goda tiden

 

Microsoft OLE DB Provider for ODBC Drivers error '80040e10'

 

[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

 

/medlemsregister/tavling/spara_forening.asp, line 48

 

<%

Dim id, Forening, Kontaktpers, Kontakttele, Kontaktmail, Kontaktadress, Kontaktpostnr, Kontaktort, Presentation

Dim Lag1, Press1, Lag2, Press2, Lag3, Press3, Lag4, Press4, Lag5, Press5, Lag6, Press6, Lag7, Press7, Lag8,

Press8

Dim cnt, Nyckel

Dim idt, Kontaktperson, Kontaktpostadress, Kontakttelefon

Dim Conn, sSQL, RS, idt2

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

Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("funkfiler/Tavling.mdb")

 

idt2 = Session("username")

idt = "101"

 

 

 

 

 

 

sSQL = "UPDATE forening SET " & _

"Forening='" & Request.Form("Foreningn")& "', " & _

"Kontaktpers='" & Request.Form("Kontaktpers")& "', " & _

"Kontakttele='" & Request.Form("Kontakttele")& "', " & _

"Kontaktmail='" & Request.Form("Kontaktmail")& "', " & _

"Kontaktaddress='" & Request.Form("Kontaktadress")& "', " & _

"kontaktadress='" & Request.Form("Kontaktadress")& "', " & _

"Kontaktpostnr='" & Request.Form("Kontaktpostnr")& "', " & _

"Kontaktort='" & Request.Form("Kontaktort")& "', " & _

"Presentation='" & Request.Form("Presentation")& "', " & _

"Lag1='" & Request.Form("Lag1")& "', " & _

"Press1='" & Request.Form("Press1")& "', " & _

"Lag2='" & Request.Form("Lag1")& "', " & _

"Press2='" & Request.Form("Press1")& "', " & _

"Lag3='" & Request.Form("Lag1")& "', " & _

"Press3='" & Request.Form("Press1")& "', " & _

"Lag4='" & Request.Form("Lag1")& "', " & _

"Press4='" & Request.Form("Press1")& "', " & _

"Lag5='" & Request.Form("Lag1")& "', " & _

"Press5='" & Request.Form("Press1")& "', " & _

"Lag6='" & Request.Form("Lag1")& "', " & _

"Press6='" & Request.Form("Press1")& "', " & _

"Lag7='" & Request.Form("Lag1")& "', " & _

"Press7='" & Request.Form("Press1")& "', " & _

"Lag8='" & Request.Form("Lag1")& "', " & _

"Press8='" & Request.Form("Press1")& "' "

 

sSQL = sSQL & "WHERE Nyckel = '" & idt &"'"

 

Server.CreateObject("ADODB.Recordset")

48----------> Conn.Execute(sSQL)

Conn.Close

 

 

Set RS = Nothing

Conn.Close

 

Response.Redirect "tavling/index.asp"

 

Set Conn = Nothing

Länk till kommentar
Dela på andra webbplatser

Arkiverat

Det här ämnet är nu arkiverat och är stängt för ytterligare svar.

×
×
  • Skapa nytt...