English 中文(简体)
我如何用当地ql数据库档案从C#特定行取数据。
原标题:how do I get a cell of data from a specific row in c# with a local sql database file

因此,仅仅简单地简单地简单地简单地简单地简单地看着编号和ql数据库,我建立了一个数据库,其表格有两栏,一栏是用户名称,一栏是密码,我想知道,如何看用户名上下哪一行,并找到相应的密码(左边的人物),以便我可以比较一个日像页。

最佳回答

This is a question that is going to take you doing a bit of research. There are a plethora of tutorials on the internet on how to access data. Below I ve included one way that you can return a single value for you to get started with. You ll need to include System.Data.SqlClient.

// See http://www.connectionstrings.com/ for how to build your connection string
SqlConnection sqlConnection1 = new SqlConnection("Your Connection String");
SqlCommand cmd = new SqlCommand();
Object returnValue;

cmd.CommandText = "SELECT COUNT(*) FROM Customers";
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlConnection1;

sqlConnection1.Open();

returnValue = cmd.ExecuteScalar();

sqlConnection1.Close();

我从

问题回答

错误做法。 收集用户名称和密码,看看数据库是否有对应数据。

How to do it in C#? I like LINQ to SQL, even thought Microsoft recommends otherwise. Create a LINQ to SQL classes object in a C# project, call it MyContextClass, drop your database objects onto it. Then, in your code behind, write something like:

using (MyContextClass ctx = new MyContextClass) {
    if (ctx.SingleOrDefault(f => f.Username == txtUsername.Text && f.Password == txtPassword.Text) != null) {
        // The user got it right.
    }
}

然而,上述评论意见中储存密码的所有警告确实适用。 将这些内容综合起来,留给用户使用。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签