17-10-17, 10:22 AM
(17-10-17, 09:52 AM)a.ahmed كتب :PHP كود :
Private Sub btnCreate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnCreate.Click
If IsExistTable(txtTable.Text.Trim) Then
MsgBox("Exists", MsgBoxStyle.Exclamation)
Else
If CreateTable(txtTable.Text.Trim) Then
MsgBox("Created", MsgBoxStyle.Information)
Else
MsgBox("Fails", MsgBoxStyle.Exclamation)
End If
End If
End Sub
Function IsExistTable(ByVal tblName As String) As Boolean
Dim sql As String = _
"SELECT COUNT(*) " & _
"FROM [sqlite_master] " & _
"WHERE [type]='table' " & _
" AND [name]=@tName "
Dim cmd As New SQLiteCommand(Sql, con)
cmd.Parameters.AddWithValue("@tName", tblName)
If con.State <> ConnectionState.Open Then con.Open()
Dim ret As Integer = cmd.ExecuteScalar
con.Close()
Return If(ret > 0, True, False)
End Function
Function CreateTable(ByVal tblName As String)
Try
Dim sql As String = _
"CREATE TABLE [" & tblName & "] ( " & _
" [Field1] TEXT(10), " & _
" [Field2] TEXT(10) " & _
" ) "
Dim cmd As New SQLiteCommand(sql, con)
If con.State <> ConnectionState.Open Then con.Open()
Dim ret As Integer = cmd.ExecuteNonQuery
con.Close()
Return True
Catch ex As Exception
Return False
End Try
End Function
تم احسنت يا بطل من جديد تبهرنا بمساعدتك للشباب
شكرا وفي ميزان حسناتك

