  | 
		 		   | 
	  	    
          
            
			
	
			
			 
                ต้องการเก็บข้อมูลแบบวนลูป คือ drows("p_id") ตามจำนวนของ drows("k_count") 
 
ประมาณว่า drows("p_id") คือ 1001 
และ drows("k_count") คืิอ 5ชิ้น 
แล้วเก็บลงฐานข้อมูลคือ 
1001 
1001 
1001 
1001 
1001 
ประมาณนี้อะคับช่วยหาตัวอย่างหรือบอกแนวทีคับช่วยตอบทีนะคับ 
 
sub cf_todb(sender As Object, e As System.EventArgs) 
dim d,s as string 
sql1 = "select * from employee_tb where emp_first='" & lb2.text & "'" 
cmd1=new oledbcommand(sql1,conn) 
dim nameemp=cmd1.executereader() 
while nameemp.read() 
s=nameemp("emp_id") 
end while 
d="รับสินค้าแล้ว" 
dim sql2="insert into recive_tb (" 
sql2+="r_id,so_id,r_date,sup_id,r_price,r_tax,r_total,r_rid,r_status)" 
sql2+="values(?,?,?,?,?,?,?,?,?)" 
Dim command As New OleDbCommand(sql2,conn) 
		command.Parameters.Add("@r_id", _ 
 		OleDbType.VarChar).Value = lb1.Text 
		command.Parameters.Add("@so_id", _ 
 		OleDbType.VarChar).Value = session("num_recive") 
		command.Parameters.Add("@r_date", _ 
 		OleDbType.VarChar).Value = lb4.text 
		command.Parameters.Add("@sup_id", _ 
 		OleDbType.VarChar).Value = session("sup") 
		command.Parameters.Add("@r_price", _ 
 		OleDbType.VarChar).Value = lb_ttotal.text 
		command.Parameters.Add("@r_tax", _ 
 		OleDbType.VarChar).Value = lb_vat.Text 
		command.Parameters.Add("@r_total", _ 
 		OleDbType.VarChar).Value = lb_sum.Text 
		command.Parameters.Add("@r_rid", _ 
 		OleDbType.VarChar).Value = lb2.text 
		command.Parameters.Add("@r_status", _ 
 		OleDbType.VarChar).Value = d 
		command.ExecuteNonQuery() 
		 
 
for each drows in dtable.rows 
dim a as decimal = 0 
dim k as integer=0 
a=(drows("k_count")*drows("price")) 
dim b as string 
b="รอการบันทึกserial" 
 
sql="insert into receive_detail_tb values('" & lb1.text & "','" & drows("p_id") & "','" & drows("k_count") & "','" & drows("price") & "','" & a & "','" & b & "')" 
 
cmd=new oledbcommand(sql,conn) 
cmd.executenonquery() 
 
next 
 
for i=0 to  
response.Write("ดำเนินการรับสินค้าเรียบร้อย") 
 
 
end sub
 
 
  Tag : - - - -              
                        | 
           
          
            | 
			
                             | 
           
          
            
              
                   | 
                   | 
                   | 
               
              
                   | 
                
                    
                      | Date :
                          2010-05-03 14:53:09 | 
                      By :
                          xsodearna | 
                      View :
                          1825 | 
                      Reply :
                          1 | 
                     
                  | 
                   | 
               
              
                   | 
                   | 
                   | 
               
              | 
           
          
            | 
			 | 
           
         
	    
		             | 
		
			  |