Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 24th, 2003, 09:09 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default Working with Access DB

Do any of you have a link to updating a MS Access DB with ASP.NET. All I'm finding are examples of MSDE or SQL Server.
 
Old September 25th, 2003, 07:10 PM
Registered User
 
Join Date: Sep 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to sstory
Default

What do you want to know?
I have an ASP.NET book and have connected to Access in ASP many times. Doesn't appear to be too different. Just use the OLEDB provider.

imports system.data.oledb
dim conn as new oledbconnection=("provider=Microsoft.Jet.OLEDB.4.0 ;DATA Source=c:\whatever.mdb")

conn.open
 'do something
conn.close

What are you wanting to know?
What do you mean by updating? Are you looking for JET Syntax for the update or insert command?

Please give more info..


Shane
 
Old September 26th, 2003, 08:11 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Here is the code i have for sql server:

Sub DBUpdateDataGrid_Update(source As Object, E As DataGridCommandEventArgs)
        Dim objCommand As SqlCommand
        Dim strSQLQuery As String

        ' Our update command. I'm using parameters this time around.
        ' We'll set the parameter values a few lines down.
        strSQLQuery = "UPDATE scratch " _
            & "SET text_field = @TextValue, " _
                & "integer_field = @IntValue, " _
                & "date_time_field = @DTValue " _
            & "WHERE id = @ID"

        ' Create new command object passing it our SQL update
        ' command and telling it which connection to use.
        objCommand = New SqlCommand(strSQLQuery, objConnection)

        ' Add parameters that our SQL update command needs:
        objCommand.Parameters.Add(New SqlParameter("@ID", SqlDbType.Int))
        objCommand.Parameters.Add(New SqlParameter("@TextValue", SqlDbType.VarChar, 255))
        objCommand.Parameters.Add(New SqlParameter("@IntValue", SqlDbType.Int))
        objCommand.Parameters.Add(New SqlParameter("@DTValue", SqlDbType.DateTime))

        ' Set the values of these parameters:

        ' This comes from our datagrid telling us which item to update.
        objCommand.Parameters("@ID").Value = DBUpdateDataGrid.DataKeys(E.Item.ItemIndex)

        ' These can obviously come from anywhere... I'm just pulling
        ' in strings and numbers from the current time & date so
        ' I can keep the sample simple and not involve an input form.
        ' In a real world example you'd probably pull them from data
        ' that a user entered.
        objCommand.Parameters("@TextValue").Value = CStr(WeekdayName(WeekDay(Now())))
        objCommand.Parameters("@IntValue").Value = CInt(Day(Now()))
        objCommand.Parameters("@DTValue").Value = Now()

        ' Open the connection, execute the command, and close the connection.
        objConnection.Open()
        objCommand.ExecuteNonQuery()
        objConnection.Close()

        ' Record is now updated... you should add appropriate error handling.

        ' Refresh our Datagrid to show the record is updated with new data.
        ShowDataGrid()
    End Sub

I am confused on how to convert this for an Access DB.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Working around DB Nulls chroniclemaster1 ASP.NET 2.0 Basics 2 February 27th, 2008 03:11 AM
Converting Access DB to Online DB eyal8r Access 5 December 6th, 2004 05:22 AM
access db to sql server db mikersantiago Classic ASP Basics 4 November 16th, 2004 03:33 AM
MS OLE DB Provider for ODBC -not working 4 me humour General .NET 6 August 3rd, 2004 03:19 AM
DB Connection not working XP costrega Classic ASP Databases 7 November 11th, 2003 06:18 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.