Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click Dim filename, dbPath As String SaveFileDialog1.Filter = "MS SQL Database File (*.mdf*)|*.mdf" If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then dbPath = SaveFileDialog1.FileName filename = System.IO.Path.GetFileNameWithoutExtension(dbPath) Dim str As String Dim myConn = New SqlConnection("Data Source=.\SQLEXPRESS;Integrated security=true;database=") str = "CREATE DATABASE " + filename + ";" Dim myCommand = New SqlCommand(str, myConn) Try myConn.Open() myCommand.ExecuteNonQuery() MessageBox.Show("DataBase is Created Successfully", "New Database", MessageBoxButtons.OK, MessageBoxIcon.Information) Catch ex As Exception MessageBox.Show(ex.ToString(), "New Database", MessageBoxButtons.OK, MessageBoxIcon.Information) Finally If (myConn.State = ConnectionState.Open) Then myConn.Close() End If End Try End If End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)