Question: I am writing a code for a SQL 'Interpreter. There is an error with Items which I highlighted below. The error message: 'TextBox' does not

I am writing a code for a "SQL 'Interpreter".

There is an error with "Items" which I highlighted below.

The error message: 'TextBox' does not contain a definition for 'Items' and no accessible extension method 'Items' accepting a first argument of type 'TextBox' could be found (are you missing a using directive or an assembly reference?)

Please be specific on how to fix it, thank you!

private void Click_Run_Click(object sender, EventArgs e) //run button { try { string Buffer = System.IO.File.ReadAllText(textBox1.Text);

string[] sql_commands = Buffer.Split(new char[] { ';' });

string ConnectString = "provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + textBox2.Text;

System.Data.OleDb.OleDbConnection Connection = new System.Data.OleDb.OleDbConnection(ConnectString);

System.Data.OleDb.OleDbCommand SQLCommand = null;

Connection.Open(); // open the connection

for (int i = 0; i < sql_commands.Length - 1; i++) { textBox3.Items.Add(sql_commands[i] );

try { // make a SQL command from the query SQLCommand = new System.Data.OleDb.OleDbCommand(sql_commands[i], Connection);

SQLCommand.ExecuteNonQuery(); } catch (Exception) // error message when the user try to upload a invalid SQL query to database { MessageBox.Show("Error sending to database"); return; } }

Connection.Close(); // now the connection closed } catch (Exception) { MessageBox.Show("Error, No file selected"); }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!