I need to call to make run Mudule1 and the statement in button click is not working?
I am using VB 2017 and SQLEpress. I think something is wrong with the code from the button click. Please, I need help with this matter. Thank you in advance.
Code:
Imports System.Data.SqlClient
Public Class Form1
Private Sub BtnCreateTb_Click(sender As Object, e As EventArgs) Handles BtnCreateTb.Click
Call Main()
End Sub
End Class
Module Module1
Sub Main()
' Define your connection string (update this based on your server and database)
Dim connectionString As String = ("Server=localhost\SQLEXPRESS;Database=master;Trusted_Connection=True;")
' Define the SQL command to create a new table
Dim createTableQuery As String = "
CREATE TABLE Employees (
Re: I need to call to make run Mudule1 and the statement in button click is not worki
Calling a method Main is a bad idea. Main is often the entry point of programs, so this might cause trouble. Call it anything else.
You don't need the Call statement. That doesn't do anything for you. Some people like to do it anyways, which is fine, but it isn't necessary.
Other than that, the only clear issue is that the method Main isn't complete, but I assume you know that.