467,895 Members | 1,423 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,895 developers. It's quick & easy.

Help with VB database table creation

Expand|Select|Wrap|Line Numbers
  1. Set tblNew_Cycle = db.CreateTableDef(New_Cycle_Name)
  2.  
  3.  
  4. 'Adding Fields to the Table
  5. tblNew_Cycle.Fields.Append tblNew_Cycle.CreateField("Test_Cycle", dbText)
  6. tblNew_Cycle.Fields.Append tblNew_Cycle.CreateField("Sno", dbInteger)
  7. tblNew_Cycle.Fields.Append tblNew_Cycle.CreateField("Group_Name", dbText)
  8. tblNew_Cycle.Fields.Append tblNew_Cycle.CreateField("Test_Case", dbText)
  9. tblNew_Cycle.Fields.Append tblNew_Cycle.CreateField("Result", dbText)
  10. tblNew_Cycle.Fields.Append tblNew_Cycle.CreateField("Tester", dbText)
  11. tblNew_Cycle.Fields.Append tblNew_Cycle.CreateField("Date_Tested", dbDate)
  12. tblNew_Cycle.Fields.Append tblNew_Cycle.CreateField("CR", dbText)
  13. tblNew_Cycle.Fields.Append tblNew_Cycle.CreateField("CL", dbText)
  14. tblNew_Cycle.Fields.Append tblNew_Cycle.CreateField("Star_Team_Ref", dbText)
  15. tblNew_Cycle.Fields.Append tblNew_Cycle.CreateField("Dummy_Notes", dbText)
  16. tblNew_Cycle.Fields.Append tblNew_Cycle.CreateField("Total_Steps", dbText)
  17. tblNew_Cycle.Fields.Append tblNew_Cycle.CreateField("Failed_Step", dbText)
  18. tblNew_Cycle.Fields.Append tblNew_Cycle.CreateField("Original_Tester", dbText)
  19. tblNew_Cycle.Fields.Append tblNew_Cycle.CreateField("Review_Comments", dbText)
  20. tblNew_Cycle.Fields.Append tblNew_Cycle.CreateField("Tester_Comments", dbText)
  21. tblNew_Cycle.Fields.Append tblNew_Cycle.CreateField("Action_Taken", dbText)
  22. tblNew_Cycle.Fields.Append tblNew_Cycle.CreateField("Bug_Status", dbText)
  23. tblNew_Cycle.Fields.Append tblNew_Cycle.CreateField("Duplicate", dbText)
  24. tblNew_Cycle.Fields.Append tblNew_Cycle.CreateField("Step_Needing_Clarification", dbText)
  25.  
I created a database table in the above manner. Here New_Cycle_Name is a variable which contains the actual name which the table shld be given.
This code is placed in a loop so every time a new table shld be created with a new name.

Now my problem is
1. How do i insert values into the table using SQL Insert Into command??
I tried it in the following way:


db.Execute ("Insert into tbl_New_Cycle (Test_Cycle,Sno,Group_Name,Test_Case,Tester) values('" & New_Cycle_Name & "','" & no & "', """ & Group_Name & """, """ & Test_Case & """,'" & Tester & "')")


But while running the program i got an error saying that output table "tbl_New_Cycle" not found, This is because the table that is created in the database has a different name ex TC99..

2.Similarly I am not able to query the table for any kind of results because of the table name being different.



Any help will be appreciated. I searched the net a ot for some solution but couldn`t get any.
Thanks
Oct 25 '07 #1
  • viewed: 1546
Share:
2 Replies
debasisdas
Expert 4TB
tbl_New_Cycle is not the table name that is a variable , so how can you hardcode that one.

try this
Expand|Select|Wrap|Line Numbers
  1. db.Execute ("Insert into" & tbl_New_Cycle & "(Test_Cycle,Sno,Group_Name,Test_Case,Tester) values ('" & New_Cycle_Name & "','" & no & "', """ & Group_Name & """, """ & Test_Case & """,'" & Tester & "')")
  2.  
Nov 4 '07 #2
QVeen72
Expert 1GB
Hi,

One more correction over here : Field "SNo" is an Integer, so you should not wrap it in single Quotes..:

Check this :
Expand|Select|Wrap|Line Numbers
  1. db.Execute ("Insert into" & tbl_New_Cycle & "(Test_Cycle,Sno,Group_Name,Test_Case,Tester) values ('" & New_Cycle_Name & "'," & no & ", '" & Group_Name & '", '" & Test_Case & "','" & Tester & "')")
  2.  
Regards
Veena
Nov 4 '07 #3

Post your reply

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

Similar topics

reply views Thread by James Hong | last post: by
10 posts views Thread by shsandeep | last post: by
6 posts views Thread by Andrť | last post: by
4 posts views Thread by Brad Isaacs | last post: by
reply views Thread by SOI_0152 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.