For i As Integer = 0 To ServicebilldetailDataGridView1.Rows.Count - 1
If ServicebilldetailDataGridView1.Rows(i).Cells(5).Value IsNot Nothing Then
Dim id As String = ServicebilldetailDataGridView1.Rows(i).Cells(1).Value.ToString()
Dim strselectDEL As String = "รบกวนด้วยครับ"
com.CommandType = CommandType.Text
com.CommandText = strselectDEL
com.Connection = con
com.ExecuteNonQuery()
MsgBox("OK")
End If
Next
Tag : VS 2010 (.NET 4.x), VS 2012 (.NET 4.x)
Date :
2012-07-20 22:10:39
By :
billkyz5
View :
1100
Reply :
1
No. 1
Guest
Code (VB.NET)
For i As Integer = 0 To ServicebilldetailDataGridView1.Rows.Count - 1
If ServicebilldetailDataGridView1.Rows(i).Cells(5).Value IsNot Nothing Then
Dim id As String = ServicebilldetailDataGridView1.Rows(i).Cells(1).Value.ToString()
Dim strselectDEL As String
strselectDEL= "declare @sdid varchar(20),@seid varchar(20),@smid varchar(20)" & vbCrLf & _
"declare @name varchar(50),@price int" & vbCrLf & _
"set @sdid=ServicebilldetailDataGridView1.Rows(i).Cells(0).Value.ToString()" & vbCrLf & _
"set @seid=ServicebilldetailDataGridView1.Rows(i).Cells(1).Value.ToString()" & vbCrLf & _
"set @smid=ServicebilldetailDataGridView1.Rows(i).Cells(2).Value.ToString()" & vbCrLf & _
"set @name=ServicebilldetailDataGridView1.Rows(i).Cells(3).Value.ToString()" & vbCrLf & _
"set @price=ServicebilldetailDataGridView1.Rows(i).Cells(4).Value" & vbCrLf & _
"if(select count(*) from tablename where sdid=@sdid) = 0" & vbCrLf & _
"begin" & vbCrLf & _
"insert into tablename(sdid,seid,smid,name,price) select @sdid,@seid,@smid,@name,@price" & vbCrLf & _
"End" & vbCrLf & _
"Else" & vbCrLf & _
"begin" & vbCrLf & _
"update tablename set seid=@seid,smid=@smid,name=@name,price=@price where sdid=@sdid" & vbCrLf & _
"End"
com.CommandType = CommandType.Text
com.CommandText = strselectDEL
com.Connection = con
com.ExecuteNonQuery()
MsgBox("OK")
End If
Next