本文介绍了Vb.net和Sqlserver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查记录是否存在?而且当记录不存在时我也可以插入记录


How can check the record is exists or not? And also i can insert the record when its not existing


Private Sub AddButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddButton.Click
            con = New SqlConnection(Constr)
            con.Open()
            Dim cmdstr1 As String = "Select * from Mcdaily where Mcno=''" & McnoCombo.Text & "''and Ftime=" & DGVlogentry.Item(2, i).Value & ""
            dt = DataManager.ExecuteQuery(cmdstr1, Constr)
            If (dt.Rows.Count > 0) Then
                MessageBox.Show("Already Exists")
            Else
                 Insertcmd()
             End if
End sub

推荐答案




这篇关于Vb.net和Sqlserver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 14:54