Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases 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 December 6th, 2004, 04:39 AM
Authorized User
 
Join Date: Dec 2004
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default a doubt regarding the insertion into the Access

hi everybody and i am new to this workgroup..
i have a doubt regarding the insertion into the Access database..
i am even new to ASP and hence ..
i have done my html front end and need to insert the info into my Access database..
i have date of birth field which i have designed in Select option that is in a pull down menu to select.
so how to collect the data using Request.Form command and place it into my Access .
and how should i design my database for this field that is is that i have to create a separate field for day , month, year or a single field DOB with date/time datatype .

   plz help me and need a response quicker as i have to construct this module within a week time..



MuthuKumar.AL
__________________
MuthuKumar.AL
 
Old December 6th, 2004, 04:48 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Following code shows how to insert record in the Access database after getting in the form:

<%
' Declaring variables
Dim cname, email, add, data_source, con, sql_insert

' Receiving values from Form
cname = ChkString(Request.Form("comname"))
email = ChkString(Request.Form("email"))
add = ChkString(Request.Form("address"))
data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
Server.MapPath("sample.mdb")
sql_insert = "INSERT INTO enquiry (cname, address, email) values ('" & _
cname & "', '" & add & "', '" & email & "')"
' Creating Connection Object and opening the database
Set con = Server.CreateObject("ADODB.Connection")
con.Open data_source
con.Execute sql_insert
' Done. Close the connection
con.Close
Set con = Nothing
%>

You can use drop down or single field. If you are using text box then you have to validate the date entered.

Om Prakash
 
Old December 6th, 2004, 04:53 AM
Authorized User
 
Join Date: Nov 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to don baroo Send a message via Yahoo to don baroo
Default

Hi MuthuAl,

I feel it will be best if you create a single field with a date/time datatype for date of birth.

cheers and all the best.

don baroo

 
Old December 6th, 2004, 05:11 AM
Authorized User
 
Join Date: Dec 2004
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thx for the code i will try with that and if problem persists i will post it and an another one that is i have three seperate fields in my front end for date of birth and is that enough to create one field for date of birth in the database Access with type date/time and if yes how to insert those values into the database with just one field for date of birth

MuthuKumar.AL
 
Old December 6th, 2004, 08:45 AM
Authorized User
 
Join Date: Dec 2004
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by om_prakash
 Following code shows how to insert record in the Access database after getting in the form:

<%
' Declaring variables
Dim cname, email, add, data_source, con, sql_insert

' Receiving values from Form
cname = ChkString(Request.Form("comname"))
email = ChkString(Request.Form("email"))
add = ChkString(Request.Form("address"))
data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
Server.MapPath("sample.mdb")
sql_insert = "INSERT INTO enquiry (cname, address, email) values ('" & _
cname & "', '" & add & "', '" & email & "')"
' Creating Connection Object and opening the database
Set con = Server.CreateObject("ADODB.Connection")
con.Open data_source
con.Execute sql_insert
' Done. Close the connection
con.Close
Set con = Nothing
%>

You can use drop down or single field. If you are using text box then you have to validate the date entered.

Om Prakash

sir i executed the code you posted to me and i have an error which i tried but in vain so i put forward the error and if you aware of this error please give me the solution
   "Conn.Execute sql_insert" ----> This is the place where it had shown me a error.

MuthuKumar.AL
 
Old December 6th, 2004, 08:54 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

What is the error you are getting?

Om Prakash
 
Old December 7th, 2004, 12:46 AM
Authorized User
 
Join Date: Dec 2004
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by om_prakash
 What is the error you are getting?

Om Prakash

Mr.Om Prakash , plz help me with this..
the error i am getting is
      "Error Type:
            Microsoft JET Database Engine (0x80040E14)
            Syntax error in INSERT INTO statement
        "
 the line number where the error has been shown contains this statement "Conn.Execute sql_insert "
sql_insert contains the sql querry for inserting the item into database..
MuthuKumar.AL
 
Old December 9th, 2004, 06:33 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Comment the connection.execute method and do a response.write sql_insert before execute() method and post what comes along with the sql_insert string. Post the same here. Lets have a look at it.

Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old December 10th, 2004, 03:13 AM
Authorized User
 
Join Date: Dec 2004
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default

here i have written my code which i am having an error saying syntax error in INSERT INTO statement....

"The CoDe"

 isql ="insert into User(User_Name,MonthOfBirth,DayOfBith,YearOfBirth, Address,City,State,Pincode,************,Exp\Fre\Finalyr,Yr Of Exp,Walk-In,Telephone,eMail,Details/ClarificationsAskedFor,Person Contacted,IsDoubtsClarified) values('" & sname & "','" & mont & "','" & daay &"','" & yeear & "','" & addrr & "','" & citty & "','" & statt & "', '" & pinc & "', '" & ssex & "', '" & exxp & "', '" & yofexp & "','" & walk & "','" & tele & "','" & eemail & "','" & clarif & "','" & personn & "','" & doubt & "')"

'Connection Opening
  Set Conn = Server.CreateObject("ADODB.Connection")
  Conn.ConnectionString = "Provider =Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("Enquiry.mdb") & ";"
  Conn.Open
'Opening A RecordSet
  Set Rs=server.CreateObject("ADODB.Recordset")
  Set Rs=Conn.Execute(isql)

plz i need Answers...
i am really fed up with this plz someone clear my doubts...
bye for now


MuthuKumar.AL
 
Old December 10th, 2004, 03:59 AM
Friend of Wrox
 
Join Date: Sep 2004
Posts: 104
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to sureshbabu Send a message via Yahoo to sureshbabu
Default

In the statement "Insert into user.."
Dont use "User" as the table name. This is the keyword. Please rename it. I think it will erase this error.

Thanks
Suresh








Similar Threads
Thread Thread Starter Forum Replies Last Post
string insertion MunishBhatia ASP.NET 2.0 Professional 1 July 13th, 2007 08:20 AM
simple problem of insertion abhishek0807 ASP.NET 1.0 and 1.1 Basics 1 March 13th, 2007 08:27 AM
insertion of records in database MunishBhatia SQL Server 2005 1 December 12th, 2006 09:25 PM
error while insertion... abhit_kumar JSP Basics 0 January 24th, 2005 09:09 AM
insertion sort..please amahja56 C++ Programming 1 March 1st, 2004 09:40 PM





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