06-06-14, 02:13 AM
.....
جرب التالي
جرب التالي
كود :
Imports MySql.Data.MySqlClient
Public Class Form1
Public cn As New MySqlConnection(" Server=xxxxx.xxxx.com; " _
& " User id=medical_xxxx; " _
& " Password=xxxxxx; " _
& " Database=medical_xxxx; ")
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim table_name As String = "table1"
Dim DB1 As String = "db"
Dim txt1 As String = "abc"
MsgBox(HasRows(table_name, DB1, txt1))
End Sub
Private Function HasRows(ByVal tablename As String, ByVal DB1 As String, ByVal txt1 As String) As Boolean
Dim sql As String = " SELECT * FROM " & tablename & " WHERE " & DB1 & "= '" & txt1 & "' "
Dim da As New MySqlDataAdapter(sql, cn)
Dim dt As New DataTable
If da.Fill(dt) > 0 Then Return True
End Function
End Class


