Results 1 to 3 of 3

Thread: I need to call to make run Mudule1 and the statement in button click is not working?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2001
    Location
    Calgary
    Posts
    260

    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

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,648

    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

  3. #3
    New Member
    Join Date
    Dec 2024
    Posts
    12

    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
  •  



Click Here to Expand Forum to Full Width