【发布时间】:2013-06-01 21:20:38
【问题描述】:
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 iss_farmacie_spitali
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
sqlConnection1.Open();
sqlCommand1.Parameters.AddWithValue("user",textBox1.Text);
sqlCommand1.Parameters.AddWithValue("pass",textBox2.Text);
sqlCommand1.CommandText = "SELECT id,parola FROM ANGAJAT WHERE id=(user) AND parola=(pass)";
if (sqlCommand1.ExecuteNonQuery()!=null)
MessageBox.Show("ESTE");
sqlConnection1.Close();
}
}
}
我希望完成的是建立一个功能登录。我有一个数据库,一个名为“angajati”(员工)的表,其中包含 id(实际上是用户名)和 parola(密码)。我想知道的是,我可以在 SQL 脚本文本中引入“变量”,让它像函数一样运行,并简单地从我的文本框中传递值。这是我从其他示例中得出的,但它似乎不起作用。谁能给我一些关于这件事的见解?
【问题讨论】:
-
我想也许你应该在这里寻找你想要的答案:stackoverflow.com/questions/4624811/…
标签: c# sql-server visual-studio-2012