Robert Vando Butarbutar Robert Vando Butarbutar - 1 year ago 107
C# Question

Textbox throwing an error when empty

I just try to make

if (txtNo.Text != "" || txtName.Text != "" || txtAddress.Text != "")
MessageBox.Show("Please Fill Textbox");

enter image description here

I just click update with not value in textbox.

I just make clear when the textbox in the user press the update button, then the warning messages are displayed so that the user recharges. Without being subject to error or out of the program, I am using SQL SERVER to save data.

Answer Source

Change your button code like this.

private void btnUpdate_Click(object sender, EventArgs e)
            if (txtNo.Text == "" || txtName.Text == "" || txtAddress.Text == "")
                MessageBox.Show("Please Fill TextBox");
            SqlCommand CMD = new SqlCommand(UPDATE...
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download