Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > MS Access connection

Reply
Thread Tools

MS Access connection

 
 
sjsean
Guest
Posts: n/a
 
      01-25-2010
I've been trying for awhile to get the code below to "work" but alas
nothing seems to update the table in the database.

I have a button on a page which when clicked should insert a new
record into the database...all of this just to test that I am doing
correctly (or at this point doing something wrong). Any suggestions
on why a record never gets inserted?


<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="Default2.aspx.vb" Inherits="Default2" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:Button ID="Button1" runat="server" Text="Button" />

</div>
</form>
</body>
</html>

-------------------------------------------------------------------------

Imports System.Data.OleDb

Partial Class Default2

Inherits System.Web.UI.Page



Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim dbconn
Dim sql_statement
Dim dbcomm
Dim sqlsrcacc
dbconn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.
4.0;data source=" & Server.MapPath("App_data/testdatabase.mdb"))
dbconn.Open()
sql_statement = "Insert into tbl_photo (photo_name) values
('1')"
dbcomm = New OleDbCommand(sql_statement, dbconn)
dbconn.close()

End Sub
End Class
 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      01-25-2010
On Jan 25, 11:38*pm, sjsean <(E-Mail Removed)> wrote:
> I've been trying for awhile to get the code below to "work" but alas
> nothing seems to update the table in the database.
>
> I have a button on a page which when clicked should insert a new
> record into the database...all of this just to test that I am doing
> correctly (or at this point doing something wrong). *Any suggestions
> on why a record never gets inserted?
>
> <%@ Page Language="VB" AutoEventWireup="false"
> CodeFile="Default2.aspx.vb" Inherits="Default2" %>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head runat="server">
> * * <title></title>
> </head>
> <body>
> * * <form id="form1" runat="server">
> * * <div>
>
> * * * * <asp:Button ID="Button1" runat="server" Text="Button" />
>
> * * </div>
> * * </form>
> </body>
> </html>
>
> -------------------------------------------------------------------------
>
> Imports System.Data.OleDb
>
> Partial Class Default2
>
> * * Inherits System.Web.UI.Page
>
> * * Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> * * * * Dim dbconn
> * * * * Dim sql_statement
> * * * * Dim dbcomm
> * * * * Dim sqlsrcacc
> * * * * dbconn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.
> 4.0;data source=" & Server.MapPath("App_data/testdatabase.mdb"))
> * * * * dbconn.Open()
> * * * * sql_statement = "Insert into tbl_photo (photo_name) values
> ('1')"
> * * * * dbcomm = New OleDbCommand(sql_statement, dbconn)
> * * * * dbconn.close()
>
> * * End Sub
> End Class


dbcomm.ExecuteNonQuery is missing there
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
No "Wireless Network Connection" available in network connection =?Utf-8?B?am9raW5kYTE=?= Wireless Networking 7 10-16-2012 07:32 AM
Very annoying error: Access to the path is denied. ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity Jay ASP .Net 2 08-20-2007 07:38 PM
403 Forbidden: You were denied access because: Access denied by access control list Southern Kiwi NZ Computing 6 03-19-2006 05:19 AM
Not seeing Wireless Connection in Network Connection =?Utf-8?B?bW90b21hbm1hdHQ=?= Wireless Networking 4 03-05-2005 04:39 AM
How do I let people access the internet via an access point but not allow them access to my network yar Wireless Networking 4 09-21-2004 03:48 AM



Advertisments