473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

about insert/delete/update records in mysql server with asp code

3
about insert/delete/update records in mysql server with asp code

how can I insert record in mysql database.. I insert into database but if I leave one text box empty, its give me error how can overcome on it...

my code is like
"INSERT INTO hamp6 VALUES ('" & request.QueryString("FRAME_WORK_ARRANGEMENT_REF_NU M")& "', '" & request.QueryString("TASK_ORDER_FORM_REFERENCE_NUM BER") &"', '" & request.QueryString ("TASK_TITLE") &"', '" & request.QueryString ("PROJECT_SPONSOR") &"', '" & request.QueryString("TEL") &"', '" & request.QueryString("PROPOSED_TASK")&"', '" & request.QueryString("DURATION")&"', '" & request.QueryString("BUSINESS_CASE") &"', '" & request.QueryString("TOTAL_ESTIMATE_COST")&"')"
Mar 5 '07 #1
3 6146
jhardman
3,406 Expert 2GB
about insert/delete/update records in mysql server with asp code

how can I insert record in mysql database.. I insert into database but if I leave one text box empty, its give me error how can overcome on it...

my code is like
"INSERT INTO hamp6 VALUES ('" & request.QueryString("FRAME_WORK_ARRANGEMENT_REF_NU M")& "', '" & request.QueryString("TASK_ORDER_FORM_REFERENCE_NUM BER") &"', '" & request.QueryString ("TASK_TITLE") &"', '" & request.QueryString ("PROJECT_SPONSOR") &"', '" & request.QueryString("TEL") &"', '" & request.QueryString("PROPOSED_TASK")&"', '" & request.QueryString("DURATION")&"', '" & request.QueryString("BUSINESS_CASE") &"', '" & request.QueryString("TOTAL_ESTIMATE_COST")&"')"

I always make it look more like:
Expand|Select|Wrap|Line Numbers
  1. objRS.addNew
  2. for each fld in objRS.fields
  3.    if request.QueryString(fld.name) <> "" then
  4.       objRS(fld.name) = request.QueryString(fld.name)
  5.    else
  6.       'supply a default value usually with some complex function if needed
  7.       objRS(fld.name) = supplyDefault(fld.name)
  8.    end if
  9. next
  10. objRS.update
  11.  
Of course you could always specify in your database that some fields are optional.

Jared
Mar 5 '07 #2
ebru
3
But this is insert data to Access database I want to insert data to MS Sql database..How can I do this?

I did like:
if request.queryString <> "" then
query = "select FRAME_WORK_ARRANGEMENT_REF_NUM,TASK_TITLE from hamp6 where"

if request.queryString("FRAME_WORK_ARRANGEMENT_REF_NU M") <> "" then
query = query + " FRAME_WORK_ARRANGEMENT_REF_NUM like '" & replace(request.queryString("FRAME_WORK_ARRANGEMEN T_REF_NUM"), "'", "''") & "' and"
end if

but it is not working :(




***************************
I always make it look more like:
Expand|Select|Wrap|Line Numbers
  1. objRS.addNew
  2. for each fld in objRS.fields
  3.    if request.QueryString(fld.name) <> "" then
  4.       objRS(fld.name) = request.QueryString(fld.name)
  5.    else
  6.       'supply a default value usually with some complex function if needed
  7.       objRS(fld.name) = supplyDefault(fld.name)
  8.    end if
  9. next
  10. objRS.update
  11.  
Of course you could always specify in your database that some fields are optional.

Jared
Mar 6 '07 #3
jhardman
3,406 Expert 2GB
But this is insert data to Access database I want to insert data to MS Sql database..How can I do this?
There is no difference between the way you access an MS Access db and a MS SQL Server db through an ASP. You will create an ADODB object, then use SQL statements to extract and manipulate the data.
I did like:
if request.queryString <> "" then
query = "select FRAME_WORK_ARRANGEMENT_REF_NUM,TASK_TITLE from hamp6 where"

if request.queryString("FRAME_WORK_ARRANGEMENT_REF_NU M") <> "" then
query = query + " FRAME_WORK_ARRANGEMENT_REF_NUM like '" & replace(request.queryString("FRAME_WORK_ARRANGEMEN T_REF_NUM"), "'", "''") & "' and"
end if

but it is not working :(
Try a quick experiment. Test the page in a way you think should work, but have a couple things written by the server. I would have the finished query statement and the original request queryString written right before executing the query:
Expand|Select|Wrap|Line Numbers
  1. response.write "<p>request('FRAME_WORK_ARRANGEMENT_REF_NUM'): " & request.queryString("FRAME_WORK_ARRANGEMENT_REF_NUM") & vbNewLine
  2. response.write "<p>Query: " & query & vbNewLine
  3.  
Do both of these have the right data that they should have? Let me know.

Jared
Mar 6 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Sans Spam | last post by:
Greetings! I have a table that contains all of the function permissions within a given application. These functions are different sections of a site and each has its own permissions (READ, WRITE,...
3
by: xMANIGHTx | last post by:
I'm new to DTS. I read some docs before adventuring into this matter. I still haven't found in all the docs I read if there is some "built-in" DTS task or function or wathever, to do a mixed...
14
by: serge | last post by:
I have a scenario where two tables are in a One-to-Many relationship and I need to move the data from the Many table to the One table so that it becomes a One-to-One relationship. I need to...
2
by: kennethgrice | last post by:
Hi, I am new to ASP.net and visual studio.net. I have created a new ASP.NET Web Application and have started with a simple form. I have created a simple test database that will store a...
3
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all...
9
by: DraguVaso | last post by:
Hi, I'm writing a VB.NET application who has to insert/update and delete a whole bunch of records from a File into a Sql Server Database. But I want to be able to knwo the 'result' of my ctions....
4
by: =?Utf-8?B?UmljaA==?= | last post by:
On a form - I have a datagridview which is docked to the entire form. The datagridview allows users to Delete and/or Add Rows. On the Form_Load event I Fill the datagridview source table with a...
0
chumlyumly
by: chumlyumly | last post by:
Hello scripters - OS: Mac OSX Language: PHP w/ MySQL database I've created an insert page where a user inputs his info, which then goes to four different tables in a MySQL database. The...
21
by: bruno_guedesav | last post by:
I've made a function to fetch all results as an array of result- arrays. Getting the result arrays is easy, via mysql_fetch_array, and function itself is quite simple, as follows: function...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.