-
Dec 14th, 2024, 10:42 AM
#1
Thread Starter
Hyperactive Member
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 (
Last edited by Shaggy Hiker; Dec 14th, 2024 at 03:47 PM.
Reason: Added CODE tags.
mannyso
-
Dec 14th, 2024, 03:50 PM
#2
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.
My usual boring signature: Nothing
-
Jan 9th, 2025, 04:52 PM
#3
New Member
Re: I need to call to make run Mudule1 and the statement in button click is not worki
the issue might be with how the Main() method is being called. Try debugging to see if it’s hitting the Main() method. Also, make sure the SQL query is complete and properly formatted.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|