Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Problem inserting a record into An Access Database via ASPX

$
0
0
Having fits trying to insert a record. I've made a sample (see below), I can connect and query the table, but adding a record is giving me fits. first I got
"Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype." So I tried every combination of cursortype and locktype but keep getting "Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another." I must be doing something wrong. It's an Access 2007 database on a web server. I eliminated some of the connection string for security in the open below, but it does connect.
<code>
<%@ LANGUAGE = "VB" aspcompat = "true" %>

<%
Dim conn as object
conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.ACE.OLEDB.12.0"
conn.Open("wwwroot\App_Data\LooseGems.accdb")

Dim rs as object
Dim strSQL as String
strSQL = "Select WorkID from Cart where ProductId=5005"
rs=Server.CreateObject("ADODB.recordset")
rs.ActiveConnection = conn
rs.CursorType = adOpenStatic
rs.LockType = adLockPessimistic
rs.CursorLocation = adUseServer

rs.Source = strSQL

rs.Open()
rs.AddNew
rs.WorkID = "gobblygook" ' request("WorkID")
rs.ProdID = "9999" ' request("ProductID")
rs.Edate = "06/29/2013" 'request("Edate")
rs.Price = 99.99 'request("Price")
rs.PName = "Test Product" 'request("PName")
rs.imagepath = "image/path" 'request("imagepath")
rs.Weight = 12.3 'request("Weight")
rs.Cut = "brilliant" 'request("Cut")
rs.Color = "blue" ' request("Color")
rs.Stone = "Topaz" ' request("Stone")
rs.Update


rs.Close
rs = Nothing
conn.Close
conn = Nothing
%>

Viewing all articles
Browse latest Browse all 13329

Trending Articles