473,322 Members | 1,232 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,322 software developers and data experts.

Query insert into

263 100+
Hi all.

I have this values:

Expand|Select|Wrap|Line Numbers
  1. R, S, T, G
  2. 1, 2, 3, 4
  3. 1, 2, 3, 4
  4. 1, 2, 3, 4
  5. 1, 2, 3, 4
  6. 1, 2, 3, 4
  7. P, N, P, N
  8. BF, CC, BF, CC
I need insert this values in the table of db mysql in this mode:


Expand|Select|Wrap|Line Numbers
  1. TEST    A    B    C    D    E    F
  2.  
  3. R        1     1  1    1    P    BF
  4. S        2     2  2    2    N    CC
  5. T        3     3  3    3    P    BF
  6. G        4     4  4    4    N    CC
  7.  

Can you help me?
thanks
Jul 29 '08 #1
5 1301
DrBunchman
979 Expert 512MB
Hi viki,

What is it exactly that you don't know how to do? Do you know how to insert data into a MySQL database? Or is it converting the data into the required format to insert it that's causing you problems?

How are you receiving this data e.g. XML File, text file, form submission etc.

Dr B
Jul 30 '08 #2
viki1967
263 100+
Hi Dr. , thanks x your answer.

The code ASP this is:

Expand|Select|Wrap|Line Numbers
  1.  
  2. response.write trim(request.form("fase")) &"<br>" &_
  3.                trim(request.form("V_prova")) &"<br>" &_
  4.                trim(request.form("I_prova")) &"<br>" &_
  5.                trim(request.form("V_scarica")) &"<br>" &_
  6.                trim(request.form("durata")) &"<br>" &_
  7.                trim(request.form("V_applicata")) &"<br>" &_
  8.                trim(request.form("esito")) &"<br>" &_
  9.                trim(request.form("modalita")) &"<br><br>"
  10.  
  11. ReDim arrayForm(1, 255)
  12. intIndice = 0
  13.  
  14. For Each varItem in Request.Form
  15. If Request.Form(varItem).count > 1 Then
  16.  
  17. For intLoop = 1 to Request.Form(varItem).count 
  18.  
  19. arrayForm(0, intIndice) = varItem & "(" & intLoop & ")"
  20. arrayForm(1, intIndice) = Request.Form(varItem)(intLoop)
  21. intIndice = intIndice + 1
  22. Next
  23. Else 
  24.  
  25. arrayForm(0, intIndice) = varItem
  26. arrayForm(1, intIndice) = Request.Form(varItem)
  27. intIndice = intIndice + 1
  28. End If
  29. Next
  30.  
  31. ReDim Preserve arrayForm(1, intIndice - 1)
  32.  
  33. For intIndice = 0 To UBound(arrayForm, 2)
  34. Response.Write arrayForm(0, intIndice) & " = " _
  35. & arrayForm(1, intIndice) & "<BR>"
  36.  
  37. strSQL = "INSERT INTO " 
  38. strSQL = strSQL & "  tbl_2 " 
  39. strSQL = strSQL & " ( " 
  40. strSQL = strSQL & "  PROVA, "
  41. strSQL = strSQL & "  A, "
  42. strSQL = strSQL & "  B, "
  43. strSQL = strSQL & "  C, "
  44. strSQL = strSQL & "  D, "
  45. strSQL = strSQL & "  E, "
  46. strSQL = strSQL & "  F "
  47. strSQL = strSQL & " ) " 
  48. strSQL = strSQL & " VALUES " 
  49. strSQL = strSQL & " ( " 
  50. strSQL = strSQL & " '" & arrayForm1(i) & "', "
  51. strSQL = strSQL & "  " & arrayForm2(i) & ", "
  52. strSQL = strSQL & "  " & arrayForm3(i) & ", "
  53. strSQL = strSQL & "  " & arrayForm4(i) & ", "
  54. strSQL = strSQL & "  " & arrayForm5(i) & ", "
  55. strSQL = strSQL & " '" & arrayForm6(i) & "', "
  56. strSQL = strSQL & " '" & arrayForm7(i) & "' "
  57. strSQL = strSQL & " ) " 
  58. cn.execute(strSQL)
  59.  
  60. Next
  61.  
  62.  
The error in the query is:

Error Type:
Error run-time Microsoft VBScript (0x800A0009)

Why?
Jul 30 '08 #3
DrBunchman
979 Expert 512MB
Your array is out of range. Which line is it erroring on?
Jul 31 '08 #4
viki1967
263 100+
Hi Dr.

My problem is this.

I have this values of request.form:

Expand|Select|Wrap|Line Numbers
  1. A, B, C
  2. 1, 5, 9
  3.  
I see this values for column and insert in the db mysql in this mode:

Expand|Select|Wrap|Line Numbers
  1.  
  2. INSERT INTO MyTbl ( Text, Number ) VALUES ( 'A', 1 )
  3. INSERT INTO MyTbl ( Text, Number ) VALUES ( 'B', 5 )
  4. INSERT INTO MyTbl ( Text, Number ) VALUES ( 'C', 9 )
  5.  
  6.  
Do you understand my?
Jul 31 '08 #5
viki1967
263 100+
All ok people!!!!

The solution is:

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);
Property of db mysql:

http://dev.mysql.com/doc/refman/5.0/en/insert.html
Jul 31 '08 #6

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

Similar topics

6
by: Bob Bedford | last post by:
I've a table on mysql: code1 tinyint, code2 tinyint, notcode1 varchar(20),notcode2 varchar(20),label I do have some records: values(1,null,null,null,'text1');...
2
by: Philip Hachey | last post by:
I think this is do-able, and possibly even simple, but it's been too many years since I've done anything significant with SQL. Any help would be appreciated. I have two tables, PAY and CHG. ...
4
by: Spark | last post by:
Hi, Situation: Need a query to return number of ticket records by month of open in a log table where the ticket open record is older than 24 hours then the ticket pending or ticket closed...
3
by: Myron | last post by:
I'm trying to create a query that will tell me which requests took longer than 10 days to move one from particular state to another state. The query I've created returns the correct requests, but...
2
by: KoliPoki | last post by:
Greetings. I'm having a little trouble with a query. The idea is simple I need to display a list of recently unique visited URLs and the last time I visited. I have 2 table one stores the...
5
by: kjaggi | last post by:
-- tested schema below -- -- create tables -- create table tbl_test (serialnumber char(12)) go create table tbl_test2 (serialnumber char(12), exportedflag int) go --insert data --
7
by: KoliPoki | last post by:
Hello every body. I have a small issue. Problem: I have a table with 4 descriptor columns (type). I need to formulate a query to retrieve a count for each type so I can group by...etc. The...
0
by: phlype.johnson | last post by:
I'm struggling to find the best query from performance point of view and readability for a normalized DB design. To illustrate better my question on whether normalized designs lead to more complex...
3
by: Jennifer | last post by:
I have a table that I am trying to do a query on. Table is named GPFCount2. CREATE TABLE ( NULL , NULL , NULL , NULL , NULL ,
2
by: Dinesh | last post by:
Hi experts, I am working on SQL Server 2005. Now i have to write a query which will extract some information from a table. My main table is having few columns supose 3 columns. EmpID ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.