Sub deleteData()
Dim cmd As New SqlCommand
Dim da As New SqlDataAdapter
Dim dt As New DataTable
Dim ds As New DataSet
Dim strID As Integer '= 27
Dim strPartNo As String
Dim strFunc As String
Dim strHandle As String
Dim strMirror As String
Dim strUserDef1 As String
Dim strUserDef2 As String
Dim strUserDef3 As String
Dim strUserDef4 As String
Dim strUserDef5 As String
Dim i As Integer = 1
Try
' i = tempMaxsrvqgateDelete
' For i = tempMaxsrvqgateDelete To tempMaxsrvArmDelete
'i = tempMaxsrvArmDelete - 1
' If i = tempMaxsrvArmDelete Then
'Exit Sub
' Else
i = i + tempMaxsrvqgateDelete
' With cmd
'.Connection = mycon
'.CommandType = CommandType.Text
' .CommandText = "select * from Tape"
' End With
'da.SelectCommand = cmd
' da.Fill(ds, "show") 'Keep data to Dataset
' strID = ds.Tables("show").Rows.Item(i - 1)("ID").ToString
strID = i
' While (tempMaxsrvQgate < tempMaxsrvArm)
'tempMaxsrvArm = tempMaxsrvArm - 1
' strPartNo = ds.Tables("show").Rows.Item(tempMaxsrvqgateDelete)("Partno").ToString
' strFunc = ds.Tables("show").Rows.Item(tempMaxsrvqgateDelete)("Func").ToString
'strHandle = ds.Tables("show").Rows.Item(tempMaxsrvArm - 1)("Handle").ToString
'strMirror = ds.Tables("show").Rows.Item(tempMaxsrvArm - 1)("Mirror").ToString
'strUserDef1 = ds.Tables("show").Rows.Item(tempMaxsrvArm - 1)("UserDef1").ToString
'strUserDef2 = ds.Tables("show").Rows.Item(tempMaxsrvArm - 1)("UserDef2").ToString
'strUserDef3 = ds.Tables("show").Rows.Item(tempMaxsrvArm - 1)("UserDef3").ToString
' strUserDef4 = ds.Tables("show").Rows.Item(tempMaxsrvArm - 1)("UserDef4").ToString
' strUserDef5 = ds.Tables("show").Rows.Item(tempMaxsrvArm - 1)("UserDef5").ToString
With cmdCE
.Connection = conCE
.CommandType = CommandType.Text
.CommandText = "delete from [Tape] " & _
"Where id = '" & strID & "'"
' "Where id = '" & strID & "'and Partno = '" & strPartNo & "' "
End With
cmdCE.ExecuteNonQuery()
' End If
' Next
' End While
' MessageBox.Show("Save Successfully")
ShowData()
' conCE.Close()
Catch exsql As SqlCeException
MsgBox(exsql.Message, MsgBoxStyle.Exclamation)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation)
End Try
End Sub
Sub updateData()
Dim cmd As New SqlCommand
Dim da As New SqlDataAdapter
Dim dt As New DataTable
Dim ds As New DataSet
Dim strID As Integer
Dim strPartNo As String
Dim strFunc As String
Dim strHandle As String
Dim strMirror As String
Dim strUserDef1 As String
Dim strUserDef2 As String
Dim strUserDef3 As String
Dim strUserDef4 As String
Dim strUserDef5 As String
Dim tempMaxsrvQgateUP As Integer
Dim tempMaxsrvArmUP As Integer
Try
With cmd
.Connection = mycon
.CommandType = CommandType.Text
.CommandText = "select max(ID) as maxsrvQgateUP from Tape"
End With
da.SelectCommand = cmd
da.Fill(ds, "Show") 'Keep data to Dataset
tempMaxsrvQgateUP = ds.Tables("show").Rows(0)(0).ToString
'Select Data from srvARM
With cmdCE
.Connection = conCE
.CommandType = CommandType.Text
.CommandText = "select max(ID) as maxsrvArmUP from Tape"
End With
daCE = New SqlCeDataAdapter(cmdCE)
daCE.Fill(dtCE) 'Keep data to Datatable
tempMaxsrvArmUP = dtCE.Rows(0)(0).ToString
tempMaxsrvQgateUP = tempMaxsrvQgateUP + 1
tempMaxsrvArmUP = tempMaxsrvArmUP + 1
While (tempMaxsrvQgateUP <> 1)
tempMaxsrvQgateUP = tempMaxsrvQgateUP - 1
tempMaxsrvArmUP = tempMaxsrvArmUP - 1
With cmd
.Connection = mycon
.CommandType = CommandType.Text
.CommandText = "select * from Tape"
End With
da.SelectCommand = cmd
da.Fill(ds, "show") 'Keep data to Dataset
strID = ds.Tables("show").Rows(tempMaxsrvArmUP)("ID")
strPartNo = ds.Tables("show").Rows.Item(tempMaxsrvArmUP)("Partno").ToString
strFunc = ds.Tables("show").Rows.Item(tempMaxsrvArmUP)("Func").ToString
strHandle = ds.Tables("show").Rows.Item(tempMaxsrvArmUP)("Handle").ToString
strMirror = ds.Tables("show").Rows.Item(tempMaxsrvArmUP)("Mirror").ToString
strUserDef1 = ds.Tables("show").Rows.Item(tempMaxsrvArmUP)("UserDef1").ToString
strUserDef2 = ds.Tables("show").Rows.Item(tempMaxsrvArmUP)("UserDef2").ToString
strUserDef3 = ds.Tables("show").Rows.Item(tempMaxsrvArmUP)("UserDef3").ToString
strUserDef4 = ds.Tables("show").Rows.Item(tempMaxsrvArmUP)("UserDef4").ToString
strUserDef5 = ds.Tables("show").Rows.Item(tempMaxsrvArmUP)("UserDef5").ToString
With cmdCE
.Connection = conCE
.CommandType = CommandType.Text
.CommandText = "UPDATE Tape SET " & _
"Func = '" & strFunc & "',Handle='" & strHandle & "',Mirror='" & strMirror & "',UserDef1='" & strUserDef1 & "',UserDef2='" & strUserDef2 & "',UserDef3='" & strUserDef3 & "',UserDef4='" & strUserDef4 & "',UserDef5='" & strUserDef5 & "' " & _
"Where id = '" & strID & "'and Partno = '" & strPartNo & "' "
End With
cmdCE.ExecuteNonQuery()
End While
MessageBox.Show("Update Successfully")
ShowData()
conCE.Close()
Catch exsql As SqlCeException
MsgBox(exsql.Message, MsgBoxStyle.Exclamation)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation)
End Try
End Sub
Sub insertData()
Dim cmd As New SqlCommand
Dim da As New SqlDataAdapter
Dim dt As New DataTable
Dim ds As New DataSet
Dim strID As Integer
Dim strPartNo As String
Dim strFunc As String
Dim strHandle As String
Dim strMirror As String
Dim strUserDef1 As String
Dim strUserDef2 As String
Dim strUserDef3 As String
Dim strUserDef4 As String
Dim strUserDef5 As String
Try
While (tempMaxsrvArm < tempMaxsrvQgate)
tempMaxsrvArm = tempMaxsrvArm + 1
With cmd
.Connection = mycon
.CommandType = CommandType.Text
.CommandText = "select * from Tape"
End With
da.SelectCommand = cmd
da.Fill(ds, "show") 'Keep data to Dataset
strID = ds.Tables("show").Rows.Add(tempMaxsrvArm)("ID").ToString
strPartNo = ds.Tables("show").Rows.Item(tempMaxsrvArm - 1)("Partno").ToString
strFunc = ds.Tables("show").Rows.Item(tempMaxsrvArm - 1)("Func").ToString
strHandle = ds.Tables("show").Rows.Item(tempMaxsrvArm - 1)("Handle").ToString
strMirror = ds.Tables("show").Rows.Item(tempMaxsrvArm - 1)("Mirror").ToString
strUserDef1 = ds.Tables("show").Rows.Item(tempMaxsrvArm - 1)("UserDef1").ToString
strUserDef2 = ds.Tables("show").Rows.Item(tempMaxsrvArm - 1)("UserDef2").ToString
strUserDef3 = ds.Tables("show").Rows.Item(tempMaxsrvArm - 1)("UserDef3").ToString
strUserDef4 = ds.Tables("show").Rows.Item(tempMaxsrvArm - 1)("UserDef4").ToString
strUserDef5 = ds.Tables("show").Rows.Item(tempMaxsrvArm - 1)("UserDef5").ToString
With cmdCE
.Connection = conCE
.CommandType = CommandType.Text
.CommandText = "INSERT INTO [Tape] ([ID], [PartNo],Func,Handle,mirror,UserDef1,UserDef2,UserDef3,UserDef4,UserDef5) VALUES " & _
"('" & strID & "','" & strPartNo & "','" & strFunc & "','" & strHandle & "','" & strMirror & "','" & strUserDef1 & "','" & strUserDef2 & "','" & strUserDef3 & "','" & strUserDef4 & "','" & strUserDef5 & "')"
End With
cmdCE.ExecuteNonQuery()
End While
' MessageBox.Show("Save Successfully")
ShowData()
conCE.Close()
Catch exsql As SqlCeException
MsgBox(exsql.Message, MsgBoxStyle.Exclamation)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation)
End Try
End Sub
Sub deleteData()
Dim cmd As New SqlCommand
Dim da As New SqlDataAdapter
Dim dt As New DataTable
Dim ds As New DataSet
Dim strID As Integer '= 27
Dim strPartNo As String
Try
While (tempMaxsrvQgate <= tempMaxsrvArm)
tempMaxsrvQgate = tempMaxsrvQgate + 1
With cmdCE
.Connection = conCE
.CommandType = CommandType.Text
.CommandText = "select * from Tape"
End With
daCE = New SqlCeDataAdapter(cmdCE)
daCE.Fill(dtCE) 'Keep data to Datatable
strID = dtCE.Rows(tempMaxsrvQgate)("ID").ToString
strPartNo = dtCE.Rows(tempMaxsrvQgate)("PartNo").ToString
With cmdCE
.Connection = conCE
.CommandType = CommandType.Text
.CommandText = "delete from [Tape] " & _
"Where id = '" & strID & "'and Partno = '" & strPartNo & "' "
' "Where id = '" & strID & "'"
End With
cmdCE.ExecuteNonQuery()
' End If
' Next
' MessageBox.Show("Delete Successfully")
End While
MessageBox.Show("Delete Successfully")
ShowData()
' conCE.Close()
Catch exsql As SqlCeException
MsgBox(exsql.Message, MsgBoxStyle.Exclamation)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation)
End Try
End Sub