Private Sub cmdCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCreate.Click If InStr(LCase(txtDbName.Text),".sdf") = 0 Then txtDbName.Text = txtDbName.Text & ".sdf" End If If Len(Trim(txtDbName.Text)) = 0 Then MsgBox ("Please enter a Database Name ", vbInformation, "Db Name") txtDbName.Focus Exit Sub End If
if file_exists(txtdbname.Text) Then Msgbox (txtdbname.text & " already exists!", vbInformation, "Db Name") txtDbName.Focus Exit Sub End If
'Create the new database. Dim engine As New SqlCeEngine("Data Source = " & txtdbname.Text) engine.CreateDatabase() 'Create a connection to the new database. Dim ssceconn As New SqlCeConnection("Data Source = " & txtdbname.Text) 'Open the connection, execute the queries, close the connection. ssceconn.Open() Dim strSql as String
'Create the createTable command on the connection.
Dim createTable As SqlCeCommand = ssceconn.CreateCommand() Dim createIndex As SqlCeCommand = ssceconn.CreateCommand() Cursor.Current = Cursors.WaitCursor Application.DoEvents() txtProgress.text = txtprogress.text & "Creating image_tables" & vbcrlf 'Create Table image_tables strSql = "Create Table " & chr(34) & "image_tables" & chr(34) & "(" strSql = strSql & chr(34) & "image_table" & chr(34) & " nvarchar(16) NOT NULL , " strSql = strSql & chr(34) & "sql_table" & chr(34) & " nvarchar(16) NOT NULL )" createTable.CommandText = strSql Try createTable.ExecuteNonQuery() Catch ex As SqlCeException DisplaySQLCEErrors (ex) End Try
Application.DoEvents()
txtProgress.text = txtprogress.text & "Creating Suppliers" & vbcrlf
|