visual web d and Access

  • Thread starter Thread starter barret bonden
  • Start date Start date
B

barret bonden

(perhaps the wrong NG -)
the DB tools in VWD dont pick up on the autonumber key field in Access (they
edit fine) - the key field is not displayed, but neither is it updated and
so of course "add" bombs -
 
¤ (perhaps the wrong NG -)
¤ the DB tools in VWD dont pick up on the autonumber key field in Access (they
¤ edit fine) - the key field is not displayed, but neither is it updated and
¤ so of course "add" bombs -

Can you be more specific? Which tools are you referring to?


Paul
~~~~
Microsoft MVP (Visual Basic)
 
I get this same behavior with form, detailview and gridview(mostly
working with the latter 2); they create paged tables of data , and
edit/insert/delete links - the edit links work fine - but the "add" link
shows all fields but the key field and fails to add - interestingly I got so
frustrated I pasted in some old asp code(see below) and it worked fine (I
rather liked that - good of MS to carry the old functionality forward) .
I'll paste in some of the new code here as well - I can't read it well yet ,
but it does appear odd vis-a-vis the id key field for the table -

<% 'This worked - on the same db, same table
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsAddComments 'Holds the recordset for the new record to be added
Dim strSQL 'Holds the SQL query to query the database

'1Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")
'2Set an active connection to the Connection object using a DSN-less
connection
'adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("t.mdb")
'adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;" "Data Source=" &
Server.MapPath("t.mdb")

adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("t.mdb")


' adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
' DataSource=" & Server.MapPath("t.mdb")

'adoCon.Mode = adModeRead
'conStr = "Provider=Microsoft.Jet.OLEDB.4.0;"
'conStr = conStr & "Data source=c:\t.mdb"
'adoCon.ConnectionString = conStr



'3Create an ADO recordset object
Set rsAddComments = Server.CreateObject("ADODB.Recordset")

'4Initialise the strSQL variable with an SQL statement to query the
database
strSQL = "SELECT id,last, first FROM main;"

'5 Set the cursor type we are using so we can navigate through the
recordset
rsAddComments.CursorType = 2
'rsAddComments.CursorType = 3

'Set the lock type so that the record is locked by ADO when it is updated
rsAddComments.LockType = 3


'Open the recordset with the SQL query
rsAddComments.Open strSQL, adoCon

'Tell the recordset we are adding a new record to it
rsAddComments.AddNew

'Add a new record to the recordset
rsAddComments.Fields("last") = Request.Form("last")
rsAddComments.Fields("first") = Request.Form("first")


'Write the updated recordset to the database
rsAddComments.Update

'Reset server objects
rsAddComments.Close
Set rsAddComments = Nothing
Set adoCon = Nothing
'Redirect to the guestbook.asp page
'Response.Redirect "asp_data2.asp"
%>


asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/test.mdb"

SelectCommand="SELECT [id], [last], [first], [zip] FROM [t]"
DeleteCommand="DELETE FROM [t] WHERE [id] = ?" InsertCommand="INSERT INTO
[t] ([id], [last], [first], [zip]) VALUES (?, ?, ?, ?)"
OldValuesParameterFormatString="original_{0}" UpdateCommand="UPDATE [t] SET
[last] = ?, [first] = ?, [zip] = ? WHERE [id] = ?">

<DeleteParameters>

<asp:Parameter Name="original_id" Type="Int32" />

</DeleteParameters>

<UpdateParameters>

<asp:Parameter Name="last" Type="String" />

<asp:Parameter Name="first" Type="String" />

<asp:Parameter Name="zip" Type="String" />

<asp:Parameter Name="original_id" Type="Int32" />

</UpdateParameters>

<InsertParameters>

<asp:Parameter Name="id" Type="Int32" />

<asp:Parameter Name="last" Type="String" />

<asp:Parameter Name="first" Type="String" />

<asp:Parameter Name="zip" Type="String" />

</InsertParameters>

</asp:AccessDataSource>



 
Back
Top