Results 1 to 5 of 5

Thread: DB entry doesn't work

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    SwitzerLANd
    Posts
    65

    Question DB entry doesn't work

    hi

    can somebody tell me what wrong here? because it tells me that there is an error on line 39, and line 39 is the the last line posted here (adoCon.Execute (strSQL)
    it also tells that there is a synthax error in the INSERT INTO part
    Code:
    Set adoCon = Server.CreateObject("ADODB.Connection")
    	Set rsAddNewRecord = Server.CreateObject("ADODB.Recordset")
    	strCon = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("../dbroot/Names.mdb") 	
    adoCon.Open strCon
    			
    	strSQL = "INSERT INTO NameDB (Name, Language, Quality, Rating)"
    	strSQL = strSQL & " VALUES "
    	strSQL = strSQL & "('" & Name		
    	strSQL = strSQL & "', '" & Language	
    	strSQL = strSQL & "', '" & Quality
    	strSQL = strSQL & "', " & Rating	
    	strSQL = strSQL & "' );"
    
    	adoCon.Execute (strSQL)
    Name, Language, Quality, Rating are defined someplace upper in the code, there extracted from a form and Rating is a number in the form and coverted using this
    Code:
    Rating = "<img src=images/rating" & Request.Form("rating") & ".gif>"
    thx 4 help!

    -=R0ckAw4Y=-

  2. #2
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877

    Re: DB entry doesn't work

    Originally posted by -=R0ckAw4Y=-
    hi

    can somebody tell me what wrong here? because it tells me that there is an error on line 39, and line 39 is the the last line posted here (adoCon.Execute (strSQL)
    it also tells that there is a synthax error in the INSERT INTO part
    Code:
    Set adoCon = Server.CreateObject("ADODB.Connection")
    	Set rsAddNewRecord = Server.CreateObject("ADODB.Recordset")
    	strCon = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("../dbroot/Names.mdb") 	
    adoCon.Open strCon
    			
    	strSQL = "INSERT INTO NameDB (Name, Language, Quality, Rating)"
    	strSQL = strSQL & " VALUES "
    	strSQL = strSQL & "('" & Name		
    	strSQL = strSQL & "', '" & Language	
    	strSQL = strSQL & "', '" & Quality
    	strSQL = strSQL & "', " & Rating	
    	strSQL = strSQL & "' );"
    
    	adoCon.Execute (strSQL)
    Name, Language, Quality, Rating are defined someplace upper in the code, there extracted from a form and Rating is a number in the form and coverted using this
    Code:
    Rating = "<img src=images/rating" & Request.Form("rating") & ".gif>"
    thx 4 help!

    -=R0ckAw4Y=-
    Hi,
    There is an extra single quote at the end [ "'")"] also wrap a brace around the field name [e.g. [Name] instaead of Name], that might cause problem as its a keyword.

    Hope this helps.

    Danial
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    SwitzerLANd
    Posts
    65
    Code:
    strSQL = "INSERT INTO NameDB (Name, Language, Quality, Rating)"
    	strSQL = strSQL & " VALUES "
    	strSQL = strSQL & "('" & [Name]		
    	strSQL = strSQL & "', '" & [Language]	
    	strSQL = strSQL & "', '" & [Quality]
    	strSQL = strSQL & "', " & [Rating]	
    	strSQL = strSQL & ");"
    
    	adoCon.Execute (strSQL)
    is this what you mean? because the error is still the same
    -=R0ckAw4Y=-

  4. #4
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877
    Originally posted by -=R0ckAw4Y=-
    Code:
    strSQL = "INSERT INTO NameDB (Name, Language, Quality, Rating)"
    	strSQL = strSQL & " VALUES "
    	strSQL = strSQL & "('" & [Name]		
    	strSQL = strSQL & "', '" & [Language]	
    	strSQL = strSQL & "', '" & [Quality]
    	strSQL = strSQL & "', " & [Rating]	
    	strSQL = strSQL & ");"
    
    	adoCon.Execute (strSQL)
    is this what you mean? because the error is still the same
    This is what i meant
    VB Code:
    1. strsql = "INSERT INTO NameDB ([Name], [Language], Quality, Rating)"
    2.     strsql = strsql & " VALUES "
    3.     strsql = strsql & "('" & Name
    4.     strsql = strsql & "', '" & Language
    5.     strsql = strsql & "', '" & Quality
    6.     strsql = strsql & "', " & Rating
    7.     strsql = strsql & ");"
    8.  
    9.     adoCon.Execute (strSQL)
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    SwitzerLANd
    Posts
    65
    THX A LOT! it worx
    -=R0ckAw4Y=-

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width