I'm creating a warehouse management system, then i want when new orders are created, a customer's name be selected from a list box and that customer's selected name from a list box be the table name that will hold records of the table's order with a random number upto 200.
And for the orders table names created from customer names listed in a listbox, I want the created table to have a randomly generated number(upto 200) in order for each created order-per customer to be unique.
So from my codes I get an error that reads 'Incorrect syntax near '3142'.'
Can anyone tell me whats wrong with my codes.
Dim inte As Integer = Int((200 - 1 + 1) * Rnd() + 1) Dim con As New SqlClient.SqlConnection("data source=ADMIN-PC\SQLEXPRESS;initial catalog=Warehouse;Integrated Security=True") Dim cmd As New SqlCommand() cmd.Connection = con con.Open() cmd.CommandText = "CREATE TABLE '" & ListBox1.SelectedIndex & inte & "'(ID int ,LastName varchar(255) NOT NULL,FirstName varchar(255),Age int, PRIMARY KEY (ID))" cmd.CommandType = CommandType.Text cmd.ExecuteNonQuery()