manny cash
Member
- Joined
- Oct 19, 2024
- Messages
- 8
- Programming Experience
- Beginner
Asking for somebody who can help me, please : Thank you so much.
Imports System.Data.SqlClient
Public Class Form1
Private objCon As Object
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub btnCreateDatabase_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles BtnCreatedatabase.Click
Dim str As String
Dim myConn As SqlConnection = New SqlConnection("Server=localhost\SQLEXPRESS;Database=master;Trusted_Connection=True; ")
str = "CREATE DATABASE visitas ON PRIMARY " &
"(NAME = MyDatabase_Data, " &
" FILENAME = 'C:\Project\visitas.mdf', " &
" SIZE = 2MB, " &
" MAXSIZE = 10MB, " &
" FILEGROWTH = 10%)" &
" LOG ON " &
"(NAME = MyDatabase_Log, " &
" FILENAME = 'C:\Project\visitasLog.ldf', " &
" SIZE = 1MB, " &
" MAXSIZE = 5MB, " &
" FILEGROWTH = 10%)"
Dim myCommand As SqlCommand = New SqlCommand(str, myConn)
Try
myConn.Open()
myCommand.ExecuteNonQuery()
MessageBox.Show("Database is created successfully",
"MyProgram", MessageBoxButtons.OK,
MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show(ex.ToString())
Finally
If (myConn.State = ConnectionState.Open) Then
myConn.Close()
End If
End Try
'Create a table
Dim constr As String
Dim myconn As String = Nothing
' = "Server=localhost\SQLEXPRESS;Database=master;Trusted_Connection=True; "
myConn = New SqlConnection(constr)
myConn.Open()
myCommand = objCon.CreateCommand()
Dim strSQL As String
strSQL = "CREATE TABLE Names (LastName VARCHAR(30), FirstName VARCHAR (30))"
' Execute
myCommand.CommandText = strSQL
Try
myCommand.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
myConn.Close()
myConn = Nothing
End Sub
Private Function myconn() As String
Throw New NotImplementedException()
End Function
End Class
Imports System.Data.SqlClient
Public Class Form1
Private objCon As Object
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub btnCreateDatabase_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles BtnCreatedatabase.Click
Dim str As String
Dim myConn As SqlConnection = New SqlConnection("Server=localhost\SQLEXPRESS;Database=master;Trusted_Connection=True; ")
str = "CREATE DATABASE visitas ON PRIMARY " &
"(NAME = MyDatabase_Data, " &
" FILENAME = 'C:\Project\visitas.mdf', " &
" SIZE = 2MB, " &
" MAXSIZE = 10MB, " &
" FILEGROWTH = 10%)" &
" LOG ON " &
"(NAME = MyDatabase_Log, " &
" FILENAME = 'C:\Project\visitasLog.ldf', " &
" SIZE = 1MB, " &
" MAXSIZE = 5MB, " &
" FILEGROWTH = 10%)"
Dim myCommand As SqlCommand = New SqlCommand(str, myConn)
Try
myConn.Open()
myCommand.ExecuteNonQuery()
MessageBox.Show("Database is created successfully",
"MyProgram", MessageBoxButtons.OK,
MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show(ex.ToString())
Finally
If (myConn.State = ConnectionState.Open) Then
myConn.Close()
End If
End Try
'Create a table
Dim constr As String
Dim myconn As String = Nothing
' = "Server=localhost\SQLEXPRESS;Database=master;Trusted_Connection=True; "
myConn = New SqlConnection(constr)
myConn.Open()
myCommand = objCon.CreateCommand()
Dim strSQL As String
strSQL = "CREATE TABLE Names (LastName VARCHAR(30), FirstName VARCHAR (30))"
' Execute
myCommand.CommandText = strSQL
Try
myCommand.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
myConn.Close()
myConn = Nothing
End Sub
Private Function myconn() As String
Throw New NotImplementedException()
End Function
End Class