我只是学习如何连接C#和PostgresSQL.我想将数据从tb1(文本框)和tb2插入数据库.但我不知道如何编码我以前的代码是从数据库中选择SELECT.这是我的代码
private void button1_Click(object sender, EventArgs e)
{
bool blnfound = false;
NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;Port=5432;User Id=postgres;Password=admin123;Database=Login");
conn.Open();
NpgsqlCommand cmd = new NpgsqlCommand("SELECT * FROM login WHERE name='" + tb1.Text + "' and password = '" + tb2.Text + "'",conn);
NpgsqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
blnfound = true;
Form2 f5 = new Form2();
f5.Show();
this.Hide();
}
if (blnfound == false)
{
MessageBox.Show("Name or password is incorrect", "Message Box", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
dr.Close();
conn.Close();
}
}
Run Code Online (Sandbox Code Playgroud)
所以请帮我代码.
我正在使用WPF(C#).
我希望用户只能在富文本框中键入一行(不能按回车键).谁能告诉我如何设置这种富文本框属性?