社区
ASP
帖子详情
asp 登陆界面连接sql数据库完成登录怎么做?求大神帮忙
qq_25744253
2015-01-31 10:30:11
vs2012建了个asp登录界面,想连接数据库完成这个过程,sql 2008 建了表了,username和password,小白一个弄了半天没弄好,求大神帮帮忙
...全文
364
4
打赏
收藏
asp 登陆界面连接sql数据库完成登录怎么做?求大神帮忙
vs2012建了个asp登录界面,想连接数据库完成这个过程,sql 2008 建了表了,username和password,小白一个弄了半天没弄好,求大神帮帮忙
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
4 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
qq_25744253
2015-02-02
打赏
举报
回复
大神都忙,还好自己搞定了,就这样结贴吧
qq_25744253
2015-02-02
打赏
举报
回复
protected void button1_Click(object sender, EventArgs e) { string str = WebConfigurationManager.ConnectionStrings["con"].ToString(); string user = uname.Text; string pwd = upwd.Text; SqlConnection conn = new SqlConnection(str); string sqlsel = "select * from logininfor where username="+user+" and password="+pwd; SqlCommand comm = new SqlCommand(sqlsel,conn ); //"Select * from logininfor where username="+user+"and password="+pwd" SqlDataReader dr; //comm.Connection = conn; conn.Open(); dr = comm.ExecuteReader(); if (dr.HasRows) { Server.Execute("main.html"); Response.Write("<script>alert('登录成功');</script>"); conn.Close(); } else { Response.Write("登录失败"); conn.Close(); } } 改写了一下代码,还是不行,提示说列名无效
qq_25744253
2015-02-01
打赏
举报
回复
<configuration> <connectionStrings> <add name="con" connectionString="Data Source=localhost;Database=testproject;uid=用户名;pwd=密码" /> </connectionStrings> <system.web> <compilation debug="true" targetFramework="4.5" /> <httpRuntime targetFramework="4.5" /> </system.web> </configuration> 以上是Web.config的内容。 <form id="form1" runat="server"> <div> 用户名:<asp:TextBox ID="uname" runat="server" ></asp:TextBox><br /> 密 码: <asp:TextBox ID="upwd" runat="server" TextMode="Password" ></asp:TextBox><br /> <asp:Button ID="button1" runat="server" Text="提交" onclientclick="button1_Click()"/> </div> </form> 以上是我登陆界面的主要代码; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Web.Configuration; namespace test1 { public partial class login : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string str = WebConfigurationManager.ConnectionStrings["con"].ToString(); SqlCommand comm = new SqlCommand("Select * from logininfor"); string user = uname.Text.ToString(); string pwd = upwd.Text.ToString(); SqlDataReader dr; SqlConnection conn = new SqlConnection(str); conn.Open(); comm.Connection = conn; dr = comm.ExecuteReader(); if (dr.HasRows) { //Server.Execute("main.html"); Response.Write("<script>alert('登录成功');</script>"); } else { Response.Write("登录失败"); } } 这是login.aspx.cs的代码,现在只要我一打开页面不输入用户名和密码就直接弹出登录成功的对话框了,登录按钮的事件怎么写?我知道写在页面加载事件里是不对的,但不知道怎么把写的单击事件和按钮关联起来,还有什么都没输入就弹出登录成功对话框是为什么?求各位大侠帮忙解释一下
孟子E章
2015-02-01
打赏
举报
回复
数据库连接的写法可能存在问题,根本连不上数据库 另外,asp连接需要安装 Microsoft® SQL Server® 2008 R2 功能包 中的 Microsoft® SQL Server® 2008 R2 Native Client 下载地址 展开安装说明找 Microsoft® SQL Server® 2008 R2 Native Client http://www.microsoft.com/zh-cn/download/details.aspx?id=16978
设计与制作(
登陆
界面
).
1. 会在网页中制作表单 2. 会使用JavaScript脚本代码
完成
客户端信息完整性的检查 3. 会使用
ASP
内置对象来处理客户端提交的信息 4. 能为表单加入验证码 5. 会使用
SQL
语句检查用户名,
完成
登录
验证
将
asp
网站从Access
数据库
更改为
SQL
数据库
怎么改
求
大
神
指教!
将
asp
网站从Access
数据库
更改为
SQL
数据库
怎么改
求
大
神
指教! 这个是我自己在百度上找的,一直失败,我是小白
求
大
神
指教 <% if access_
sql
=1 then %> <% Else %> <% strConn = “Provider=
SQL
OLEDB;Data Source=192.168.1.19;User ID=sa;Password=admi...
asp
连接
远程服务器出错
求
大
神
们进
在本地进行调试可以 但是只要server换成具体的ping出来的那个地址 就会报错
求
大
神
们
帮忙
啊 跪谢 Dim adocon Dim outstr set adocon=server.createobject("adodb.connection") adocon.Open"Driver={
SQL
Server};Server=(local);UID=sa;PWD=123;"&"databas
用
asp
连接
Access
数据库
制作简单
登陆
界面
【题外话:最近
做
Internet作业,在这写一个适合初学入门的
ASP
连接
ACCESS
数据库
做
登陆
界面
的简单的例子,以慰藉我一口气把以前
做
过的系统中的PHP代码全改成
ASP
代码来临时应付作业的心情......然后,这个小例子很简单的。】 【前提条件:你已经在Windows下配置搭建了IIS服务器】 该例实现的功能为:
连接
Access
数据库
;
登陆
页面选择管理员...
java
登陆
界面
连接
sql
可以
连接
到
sql
数据库
有java
登陆
界面
ASP
28,377
社区成员
357,147
社区内容
发帖
与我相关
我的任务
ASP
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
复制链接
扫一扫
分享
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章