Пользователь
- Статус
- Оффлайн
- Регистрация
- 28 Июн 2020
- Сообщения
- 400
- Реакции
- 65
C#:
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace loseware_loader
{
public partial class register : Form
{
public register()
{
InitializeComponent();
}
private void regButton_Click(object sender, EventArgs e)
{
DB db = new DB();
MySqlCommand command = new MySqlCommand ("INSERT INTO `users` (`login`, `pass`) VALUES (NULL, '@login', '@pass' );", db.getConnection());
//MySqlCommand command = new MySqlCommand("INSERT INTO testbase (name, surname, login, password) VALUES (@name, @surname, @login, @password)", db.getConnection());
//command.Parameters.Add("@loginUser", MySqlDbType.VarChar).Value = Loginfield.Text
command.Parameters.Add("@login", MySqlDbType.VarChar).Value = loginbox.Text;
command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = passbox.Text;
//MySql.Data.MySqlClient.MySqlException: "Column count doesn't match value count at row 1"
db.openConnection();
if (command.ExecuteNonQuery() == 1)
MessageBox.Show("account created");
else
MessageBox.Show("account was not created");
db.closeConnection();
}
}
}
