sql数据源连接 [英] sql data source connectivity

查看:94
本文介绍了sql数据源连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,我正处于学习阶段.
我想学习与数据源工具的连接性.
只需使用2个文本框和2个标签名称作为用户名和密码.
以按钮名称登录.
现在在sql中创建一个数据库,并插入一个用户名和密码.
然后再次进入设计部分并添加数据源控件.然后将其与sql连接.
之后,我希望对登录按钮进行编码,就像用户输入正确的名称和密码一样,那么它应该重定向到另一个页面,否则应该显示说明用户名和密码无效的消息框.
请先生给这个编码......在C#中.
谢谢您,先生....

sir i am in just learning phase.
i want to learn connectivity with the data source tool.
just take 2 text box and 2 label name them as user name and password.
take a button name it login.
now create an database in sql.and insert one user name and password.
then again come design part and add data source control.then connect it with sql.
after that i want the coding for login button as if the user enters the correct name and password then it should redirect to another page or else it should message box stating invalid user name and password.
pls sir give this coding......in c#.
thank you sir....

推荐答案

很高兴您正在学习.这就是您学习作业的全部思路.无论如何,这里有一些指针/链接可能会对您有所帮助.祝你好运.

您可能会在此处获得几乎整个示例,请尝试理解它并根据需要进行更改:

http://www.daniweb.com/software-development/csharp/threads/24148 [ ^ ]

关于CP的相当古老但非常扎实的文章,内容涉及使用.Net进行数据访问.看看...

通过C#访问SQL Server的入门指南 [
I am glad you are learning. That''s the whole idea of your assignment, to learn. Anyways, here are some pointers/links which might help you. Good luck.

You might get almost the whole example here, try to understand it and change according to your needs:

http://www.daniweb.com/software-development/csharp/threads/24148[^]

Quite old, but very solid article on CP about data access with .Net. Have a look...

Beginners guide to accessing SQL Server through C#[^]


用于在Visual Studio中进行连接
打开服务器资源管理器
右键单击添加连接
遵循简单的步骤
创建连接后,右键单击数据库
点击属性
在属性"中将找到连接字符串.
复制此字符串.

For connectivity in visual studio
open Server Explorer
right click add Connection
Follow simple steps
After Creating Connection Right click on Database
Click on properties
In Proprties Connection String will be found.
Copy This String.

private void button1_Click(object sender, EventArgs e)
       {
           string cmd="select *from Admin where ID='"+txtFilenO.Text+"' and Password='"+textBox1.Text+"' ";
          SqlConnection con=new SqlConnection();

           con.connectionString="Paste Connection String";
            con.Open();
SqlCommand cmd1 = new SqlCommand(cmd,con);

           SqlDataReader dr = cmd1.ExecuteReader();
           if (dr.Read())
           {
               AdminMenu n = new AdminMenu();
               n.lblsser.Text = dr[0].ToString();
               n.Show();
               this.Dispose();
               this.Close();
               cmd1.Connection.Close();

           }
           else
           {
               cmd1.Connection.Close();
               MessageBox.Show("ID/Password is not valid");
           }

       }



它是向导的连接,但是您应该学习每个关键字的含义,所以请保持从Google和MSDN的收益.



it is connection from wizard,But You should learn meaning of each keyword, So keep l;earning from Google and MSDN.


这篇关于sql数据源连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆