vb.net - Multiple SQL statement using VB -
I have the following code, where I am trying to trigger multiple SQL statements.
I'm new to SQL, can someone help me with the right syntax?
Personal sub button 2_Click (sender as object, and event as ARG) button 2 handles. Click as Deck Com SqlConnection = New SqlConnection ("server = barry SqlCommand = New SqlCommand (" Create table "+ TextBox2.Text +" + "(myId INTEGER Primary key," + "My name is CRAR (50), my address CRR (255), Mibylance Float), Con Dm CMD 2 in the form of SQL Commands = New SQL Commands ("Update Tariffs Set Name = '" and Text Box 2. Text and "', Con ') Con Open ()
In VB.NET The string conjunction operator is the ampersand character actor (& amp;). You can also use the + symbol but it is not recommended because this can cause the side effects when the rotation is Ambiguo.
< P> said that you can only use one SQL command, two command texts are divided by a semicolon Also keep in mind that when possible you will always have the parameter The query should be used;
The first query can not be parameterized because you can not use a parameter to express a table name. Please make sure to check this material before using this TextBox2 content.
Personal sub button 2_Click (as the sender object, and eventArgs) button 2 handles. Con use = New SqlConnection (... .....) CMD = New SQL Commands ("Create Tab" and Textbox 2. Text & amp; _ "(MyIndji Primary Key, My Name CRAR (50), My Extract CR (255), "and _" my balance float); Update Tarrifs Set Name = @ name ", con) Open () cmd.Parameters.AddWithValue (" @ name ", TextBox2.Text) cmd.ExecuteNonQuery () End use end end is another good practice when you deal with disposable objects such as SQL connections and SQL Commands. This will ensure proper closure of the connection and settlement of both connections and commands
Comments
Post a Comment