|
资源信息 Tutorial Information
教程名称: | u3d连接网络sqlserver,并实现注册登录 教程+源码(发帖教程) |
适用引擎: | (适用引擎,为空默认为Unity) |
教程语种: | 中文 |
教程等级: | 1 |
教程格式: | 图文(请用IE9以上浏览器访问本版块) |
教程作者: | 转载自互联网 (如有问题请短消息联系作者或发表回复) |
下载地址: | 无 (兑换积分) |
登录注册功能已经做好了,还好比较顺利值得欣慰
注册界面
注册部分代码:登录部分:- using UnityEngine;
- using System.Collections;
- using Bitverse.Unity.Gui;
- using System;
- using System.Data.SqlClient;
- public class logsct : MonoBehaviour {
- int temp;
- public GUISkin txtskin;
- BitEditorStage form;
- BitWindow logwindow;
- BitTextField txtname;
- BitTextField txtpwd;
- BitButton btlog;
- BitButton btexit;
- // Use this for initialization
- void Start () {
- form = gameObject.GetComponent<BitEditorStage>();
- logwindow = form.FindControl<BitWindow>("log");
- txtname = logwindow.FindControl<BitTextField>("txtname");
- txtpwd = logwindow.FindControl<BitTextField>("txtpwd");
- btlog = logwindow.FindControl<BitButton>("btlog");
- btlog.MouseClick += bt_log;
- btexit = logwindow.FindControl<BitButton>("btexit");
- btexit.MouseClick += bt_exit;
- }
- private void bt_log(object sender, MouseEventArgs e)
- {
- if (txtname.Text != "" && txtpwd.Text != "")
- {
- SqlConnection sqlcon = new SqlConnection("Data Source=Sql1001.webweb.com,2433;Initial Catalog=DB_98CEEF_test;User Id=DB_98CEEF_test_admin;Password=testtest;");
- SqlCommand cmd = new SqlCommand();
- cmd.Connection = sqlcon;
- cmd.CommandType = System.Data.CommandType.Text;
- cmd.CommandText = "select * from user_ where user_name='"+txtname.Text+"' and user_pwd ='"+txtpwd.Text+"'";
- SqlDataAdapter da = new SqlDataAdapter(cmd);
- da.SelectCommand.Connection.Open();
- temp = int.Parse(da.SelectCommand.ExecuteScalar().ToString());
- da.SelectCommand.Connection.Close();
- if (temp != 0)
- print("login successed!");
- txtname.Text = "";
- txtpwd.Text = "";
- }
- }
- private void bt_exit(object sender, MouseEventArgs e)
- {
- txtname.Text = "";
- txtpwd.Text = "";
- logwindow.Visible = false;
- }
- // Update is called once per frame
- void Update () {
-
- }
- }
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
评分
-
查看全部评分
|