ito sir
Puwede mo bang ibigay ang iyong query sa pamamagitan ng code block? Upang maipakita mo sa amin ang iyong query, maaari mong isagawa ang sumusunod na mga hakbang:
1. Buksan ang iyong code editor at hanapin ang file na naglalaman ng query na nais mong gamitin.
2. Hanapin ang query na nais mong gamitin.
3. I-highlight ang kodigo ng query.
4. I-right click ang kodigo ng query at piliin ang "Copy" o "Cut", depende sa kung ano ang gusto mong gawin.
5. Mag-click sa "reply" button at i-paste ang kodigo ng query dito sa pamamagitan ng pag-click sa "Code Block" button sa itaas ng editor (o gamitin ang keyboard shortcut na Ctrl + Shift + C
).
Kapag naka-code block na ang iyong query, mas madaling makikita at maiintindihan ito nang mas mabuti ng mga nagtutulungan dito sa forum.
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Net.Sockets;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
namespace TRIAL_AND_ERROR
{
public partial class Form1 : Form
{
string connectionString = "server=localhost;database=mydatabase;uid=root;password=root;";
public Form1()
{
InitializeComponent();
}
private void button6_Click(object sender, EventArgs e)
{
MeExit();
}
private void MeExit()
{
DialogResult iExit;
iExit = MessageBox.Show("Confirm f you want to exit", "Save DataGridView", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (iExit == DialogResult.Yes)
{
Application.Exit();
}
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
MeExit();
}
private void button1_Click(object sender, EventArgs e)
{
dataGridView1.Rows.Add(textBox1.Text, textBox2.Text, textBox3.Text);
}
private void iDelete()
{
foreach (DataGridViewRow item in this.dataGridView1.SelectedRows)
{
dataGridView1.Rows.RemoveAt(item.Index);
}
}
private void button4_Click(object sender, EventArgs e)
{
string id = textBox1.Text;
string fullname = textBox2.Text;
string address = textBox3.Text;
MySqlConnection connection = new MySqlConnection(connectionString);
string query = "DELETE FROM account (ID, fullName, address) VALUES (@ID_Number, @FullName,
Address)";
MySqlCommand command = new MySqlCommand(query, connection);
command.Parameters.AddWithValue("@ID_Number", id);
command.Parameters.AddWithValue("@Fullname", fullname);
command.Parameters.AddWithValue("
Address", address);
connection.Open();
command.ExecuteNonQuery();
connection.Close();
MessageBox.Show("DELETED");
iDelete();
}
private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
{
iDelete();
}
private void button2_Click(object sender, EventArgs e)
{
iReset();
}
private void iReset()
{
foreach (var c in this.Controls)
{
if (c is TextBox)
{
((TextBox)c).Text = String.Empty;
}
}
int numRows = dataGridView1.Rows.Count;
for (int i = 0; i < numRows; i++)
{
try
{
int max = dataGridView1.Rows.Count - 1;
dataGridView1.Rows.Remove(dataGridView1.Rows[max]);
}
catch (Exception exe)
{
MessageBox.Show("All rows to be deleted " + exe, "DataGridView Delete",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
private void resetToolStripMenuItem_Click(object sender, EventArgs e)
{
iReset();
}
Bitmap bitmap;
private void button3_Click(object sender, EventArgs e)
{
int height = dataGridView1.Height;
dataGridView1.Height = dataGridView1.RowCount * dataGridView1.RowTemplate.Height * 2;
bitmap = new Bitmap(dataGridView1.Width, dataGridView1.Height);
dataGridView1.DrawToBitmap(bitmap, new Rectangle(0, 0, dataGridView1.Width, dataGridView1.Height));
printPreviewDialog1.PrintPreviewControl.Zoom = 1;
printPreviewDialog1.ShowDialog();
dataGridView1.Height = height;
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawImage(bitmap, 0, 0);
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button5_Click(object sender, EventArgs e)
{
string id = textBox1.Text;
string fullname = textBox2.Text;
string address = textBox3.Text;
MySqlConnection connection = new MySqlConnection(connectionString);
string query = "INSERT INTO account (ID, fullName, address) VALUES (@ID_Number, @FullName,
Address)";
MySqlCommand command = new MySqlCommand(query, connection);
command.Parameters.AddWithValue("@ID_Number", id);
command.Parameters.AddWithValue("@Fullname", fullname);
command.Parameters.AddWithValue("
Address", address);
connection.Open();
command.ExecuteNonQuery();
connection.Close();
MessageBox.Show("SAVED!");
}
}
}