Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 help with sql statement :Insert into two table

Author  Topic 

josef
Starting Member

15 Posts

Posted - 2011-01-31 : 01:30:13
I am learning from tutorial sites,book and having problem with sql statement .I cannot figure it out myself ,I will apprecite if someone help me .



CmdStr = "insert into table1 (item1,item2,item3,item4,item5,item6,item7,item8,item9,item10) values ('" & TextBox1.Text & "','"& TextBox2.Text & "','"& TextBox3.Text & "','"& TextBox4.Text & "','"& TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text "','" & TextBox9.Text &"','" & TextBox10.Text &"')"

CmdStr = "insert into table2 (item5,item6,item7,item8,item9,item10) values ('" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & "','" & TextBox9.Text & "','" & TextBox10.Text & "')"

Sachin.Nand

2937 Posts

Posted - 2011-01-31 : 01:53:14
But what is your problem ? Are you getting any errors?

PBUH

Go to Top of Page

josef
Starting Member

15 Posts

Posted - 2011-02-01 : 16:14:13
I am sorry that I could not reply timely , I get no error when I run the program ,it just didnt insert into tables.i used other statements in the code such as CmdStr = " SELECT SUM( item10 ) FROM [table1]"
when i removed sum statements the insert statements worked ,I thought about only executing multiple statement .if you have time, i would like to ask you how do i excute the sum statements along with insert statement
Go to Top of Page

ranganaath
Starting Member

18 Posts

Posted - 2011-02-01 : 16:26:56
My table is
depot party product MainGroup SubGroup Qty
AAA ABC Cable 1 Electric 1
AAA ABC M Board 1 Electronic 1
AAA ABC Pipe 2 Plastic 1
AAA ABC Bricks 2 Civil 1
AAA XYZ Cable 1 Electric 2
AAA XYZ M Board 1 Electronic 2
AAA XYZ Bricks 2 Civil 2

please any body help in getting the following out put in sql2005
Depot Party Electric Electronic Total Plastic Civil Total Grand Total
AAA ABC 1 1 2 1 1 2 4
AAA XYZ 2 2 4 0 2 2 6




ranganath
Go to Top of Page
   

- Advertisement -