473,699 Members | 2,384 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

inserting into MS access using ASP.NET/VB

Hello experts,

I'm a newbee to ASP.NET. And I have been struggling solving
this problem. But I can't do it. Can you please help me get
over this wall? Below is the code and error message:

<%@ Page Language="vb" AutoEventWireup ="true"
Codebehind="Reg isterForm.aspx. vb"
Inherits="WebAp plication1.Regi sterForm"%>
<%@ import Namespace="Syst em.data.oledb" %>
<%@ import Namespace="Syst em.data" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Register Form</title>
<script language="vb" runat="server">
Sub SubmitBtn_Click (Source As Object, ByVal E as EventArgs)

dim listError as string
dim connectionStrin g as string
connectionStrin g = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=C:\myPro ject\WebApplica tion1\UserDB1.m db;"
dim objConn = New OleDbConnection ( connectionStrin g )
dim objCommand
try
objConn.Open()
dim InsertSQL as string
Response.Write( "Connection established! <br />")

dim fname as string
dim lname as string
dim sname as string
dim eml as string
dim pwd as string
dim sex as string
fname=FN.text
lname=LN.text
sname=ScreenNam e.text
eml=Email.text
sex=Request.For m("Sex")
pwd=Password.te xt

'Create Insert statement
InsertSQL ="insert into Users (Email, FirstName, LastName,
ScreenName, Sex, Password) "
InsertSQL = InsertSQL & "values('" & eml &"', '" & fname
&"', '" & lname &"', '" & sname &"','" & sex & "', '" & pwd
&"');"
' Create OleDbCommand object
dim cmdInsert as New OleDbCommand(In sertSQL, objConn)
cmdInsert.Execu teNonQuery()

Response.Write( "Data Recorded")

catch Err as Exception
listError = Err.ToString()
Response.Write( listError)
end try
End Sub
</script>

ERROR:

System.Data.Ole Db.OleDbExcepti on: Syntax error in INSERT
INTO statement. at
System.Data.Ole Db.OleDbCommand .ExecuteCommand TextErrorHandli ng(Int32
hr) at
System.Data.Ole Db.OleDbCommand .ExecuteCommand TextForSingleRe sult(tagDBPARAM S
dbParams, Object& executeResult) at
System.Data.Ole Db.OleDbCommand .ExecuteCommand Text(Object&
executeResult) at
System.Data.Ole Db.OleDbCommand .ExecuteCommand (CommandBehavio r
behavior, Object& executeResult) at
System.Data.Ole Db.OleDbCommand .ExecuteReaderI nternal(Command Behavior
behavior, String method) at
System.Data.Ole Db.OleDbCommand .ExecuteNonQuer y() at
ASP.RegisterFor m_aspx.SubmitBt n_Click(Object Source,
EventArgs E) in
C:\myProject\We bApplication1\R egisterForm.asp x:line 39

Line 30 contains: cmdInsert.Execu teNonQuery()

Thank you for your time,
Nov 17 '05 #1
1 1990
hi,

the easiest way to spot your error would be to write you insert statement
out to screen
either using response.write or trace.write/warn.

then copy the statement and paste in directly into access, correct the
statement so it works and then make the
changes to you code.

probabally best to wrap the call to execute non query in a try block and
handle any error your self.

cheers

martin
"Kevin" <an*******@disc ussions.microso ft.com> wrote in message
news:04******** *************** *****@phx.gbl.. .
Hello experts,

I'm a newbee to ASP.NET. And I have been struggling solving
this problem. But I can't do it. Can you please help me get
over this wall? Below is the code and error message:

<%@ Page Language="vb" AutoEventWireup ="true"
Codebehind="Reg isterForm.aspx. vb"
Inherits="WebAp plication1.Regi sterForm"%>
<%@ import Namespace="Syst em.data.oledb" %>
<%@ import Namespace="Syst em.data" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Register Form</title>
<script language="vb" runat="server">
Sub SubmitBtn_Click (Source As Object, ByVal E as EventArgs)

dim listError as string
dim connectionStrin g as string
connectionStrin g = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=C:\myPro ject\WebApplica tion1\UserDB1.m db;"
dim objConn = New OleDbConnection ( connectionStrin g )
dim objCommand
try
objConn.Open()
dim InsertSQL as string
Response.Write( "Connection established! <br />")

dim fname as string
dim lname as string
dim sname as string
dim eml as string
dim pwd as string
dim sex as string
fname=FN.text
lname=LN.text
sname=ScreenNam e.text
eml=Email.text
sex=Request.For m("Sex")
pwd=Password.te xt

'Create Insert statement
InsertSQL ="insert into Users (Email, FirstName, LastName,
ScreenName, Sex, Password) "
InsertSQL = InsertSQL & "values('" & eml &"', '" & fname
&"', '" & lname &"', '" & sname &"','" & sex & "', '" & pwd
&"');"
' Create OleDbCommand object
dim cmdInsert as New OleDbCommand(In sertSQL, objConn)
cmdInsert.Execu teNonQuery()

Response.Write( "Data Recorded")

catch Err as Exception
listError = Err.ToString()
Response.Write( listError)
end try
End Sub
</script>

ERROR:

System.Data.Ole Db.OleDbExcepti on: Syntax error in INSERT
INTO statement. at
System.Data.Ole Db.OleDbCommand .ExecuteCommand TextErrorHandli ng(Int32
hr) at
System.Data.Ole Db.OleDbCommand .ExecuteCommand TextForSingleRe sult(tagDBPARAM S
dbParams, Object& executeResult) at
System.Data.Ole Db.OleDbCommand .ExecuteCommand Text(Object&
executeResult) at
System.Data.Ole Db.OleDbCommand .ExecuteCommand (CommandBehavio r
behavior, Object& executeResult) at
System.Data.Ole Db.OleDbCommand .ExecuteReaderI nternal(Command Behavior
behavior, String method) at
System.Data.Ole Db.OleDbCommand .ExecuteNonQuer y() at
ASP.RegisterFor m_aspx.SubmitBt n_Click(Object Source,
EventArgs E) in
C:\myProject\We bApplication1\R egisterForm.asp x:line 39

Line 30 contains: cmdInsert.Execu teNonQuery()

Thank you for your time,
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2166
by: sms1 | last post by:
My Participants table in Access 2002 contains about 1500 records. The Notes field is OLE. I want to use Insert Object to insert MS Word into the Notes field. It is easily done using: Insert Object, etc.; no problem for inserting one at a time. Problem: I don't want to go through this same Insert Object procedure 1500 separate times. There MUST be a way to do a "group" Insert Object in the Notes field so all 1500 are completed at once...
3
16513
by: James Alba | last post by:
Hey all, I am accessing an ms access database using .NET and C#. Like so, /* Create the database connection. */ connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Name); connection.Open(); And all is good.
9
6100
by: Zak Milas | last post by:
The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data. Is the error I get when it get dbCmd.ExecuteNonQuery();. I have 15 fields to insert, therefore I did one field at the time and found that the 13th field is the one causing the problem, this field is in size 20 and data I am entering size is 1. I took the INSERT command and entered it from Access Query and it worked, but not from...
15
4104
by: yzlin04 | last post by:
Hello, I'm new in vb.net. I have a problem in inserting a new row to a MS Access database table. There is no error message comes out when i run my program, but when i check my MS Access table, there is no record inserted. So, i don't know which line is incorrect. Here is my code: Dim desc, itemID As String itemID = txtItemID.Text desc = txtItemDesc.Text
18
4044
by: hotflash | last post by:
Hi Mark et All, I understand that you created a very professional document and a similar issue forum out there regarding to Inserting the checkbox value into MS Access using ASP however; I am so new to this stuff and have tried couple times but no luck. Sorry to waste your time again, but would appreciate if you can help me out. I have a form that has a checkbox name of ExpeditedRequest. I can't send the unchecked or checked value to the...
0
2639
by: freeskier | last post by:
Hello, Sorry for the newb question; I've spent a good amount of time trying to figure this out. I am fairly new to the Postgre world. I am currently in the process of upsizing several MS Access apps to a single PostgreSQL system; I will continue to use Access as the frontend. I have duplicated the table structure in Postgre and have successfully connected Access as a frontend to view data. I am having trouble inserting a record into...
6
11758
by: ashes | last post by:
Hi, I am creating an ecommerce website using Microsoft Visual Studio, VB.Net and MS Access 2003. I am new to VB.Net When someone wants to register on the website, they fill out a form and the contents of the form is inserted into the MS Access database. The Customer table in the database already has 30 records (with CustomerIDs 1 - 30) in it (from when the database was first created). The CustomerID field in the database is an...
2
3082
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography section: Discography --------------------- DiscID
2
3117
by: hakkatil | last post by:
Hi to all, I have a page that inserts excel sheet to access database. I am using asp. What I want to do is to check the inserting record if it is in the database. Basicly checking the dublicate record. My code inserts records one by one using addnew-updatebatch. If there is a duplicate in the db, it will display "already exists" and if it is not in the db it will display "record added". Below is my asp code I found on the net and...
1
4411
by: evenlater | last post by:
I have an Excel workbook that I'm programming from Access. The rows in the workbook vary in height. So let's say row 8 is taller than the rows above it. If I *manually* insert 2 new rows at the top, row 8 becomes row 10 and row 10 is now the taller row. That’s the way I want it to be. But when I insert lines using VBA code, row 8 remains taller and row 10 is shorter. That messes up the way my data is displayed. Is there a way to get...
0
8685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8613
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8908
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7745
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4374
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.