資源簡介
山東大學(威海)C#課的期末大作業 具體的數據庫信息自行編寫

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.Data.SqlClient;
namespace?微博test
{
?
????public?partial?class?Form1?:?Form
????{
????????public?static?string?s;
???????
????????public?Form1()
????????{
????????????InitializeComponent();
????????????this.StartPosition?=?FormStartPosition.CenterScreen;
????????}
??????
???
????????public?void?button1_Click(object?sender?EventArgs?e)
????????{
??????????
????????????string?password?=?txtPassword.Text;
????????????string?username=?txtName.Text;
????????????s?=?username;
????????????string?connectingString?=?“Integrated?Security=sspi;server=localhost;database=微博;“;
???????????//?string?sql?=?“select?Password?from?用戶信息?where?Name=@nm“;
????????????SqlConnection?conn?=?new?SqlConnection(connectingString);
????????????try
????????????{
????????????????conn.Open();?????//?打開數據庫??????????????????????
????????????????SqlCommand?cmd?=?conn.CreateCommand();?????????//創建一個數據庫命令行?
????????????????cmd.CommandText?=?“select?*?from?用戶信息$?where?Name=@UN“;???//數據庫命令的內容(@un是點位符將會在下面的語句中賦值)?
????????????????cmd.Parameters.AddWithValue(“UN“?username);??????//?將username?賦值給命令行的?“un”
????????????????SqlDataReader?reader?=?cmd.ExecuteReader();??????//?將數據庫命令執行后的結果賦值給?reader
????????????????if?(reader.Read()?==?false)??????????????????????//?reader?中的內容沒有一項是符合要求的?????
????????????????{
????????????????????lblMessage.Text?=?“用戶不存在“;??????//??提示用戶不存在????????
????????????????????return;
????????????????}
????????????????string?realpassword?=?reader.GetString(6);??//當上一句中,找到了正確的用戶名定義?realpassword為相應的用戶貯存在服務器上的密碼???
????????????????if?(password?==?realpassword)?????????????????//判斷用戶輸入的密碼是否服務器上密碼相同????????
????????????????{
????????????????????lblMessage.Text?=?“登錄成功“;
????????????????????this.Visible?=?false;
????????????????????Form?f2?=?new?Form2();
????????????????????f2.Show();
????????????????}
????????????????else?if?(password?!=?““)
????????????????{
????????????????????lblMessage.Text?=?“密碼錯誤“;???????????????//如果不相等提示登錄失敗????
????????????????}
????????????????else
????????????????????lblMessage.Text?=?“密碼不能為空“;
????????????????cmd.Dispose();
???????????????conn.Dispose();
????????????????
????????????}
????????????catch?(Exception?ex)
????????????{
????????????????MessageBox.Show(ex.Message?“讀取錯誤“);
????????????}
???????????
????????}
????????????
public?string?returnname()?
????????{
????????????string?s?=?txtName.Text;
????????????return?s;
????????}
??????????/*??using?(SqlConnection?conn?=?new?SqlConnection(connectingString))
????????????{
????????????????
????????????????????SqlCommand?cmd?=?new?SqlCommand(sql?conn);
????????????????????cmd.Parameters.AddWithValue(“nm“?username);
????????????????????try
????????????????????{
????????????????????????conn.Open();
??
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1018??2012-11-27?08:59??微博test\微博test\App.Config
?????文件?????121856??2012-12-12?17:52??微博test\微博test\bin\Debug\微博test.exe
?????文件???????1018??2012-11-27?08:59??微博test\微博test\bin\Debug\微博test.exe.config
?????文件?????237056??2012-12-12?17:52??微博test\微博test\bin\Debug\微博test.pdb
?????文件??????11600??2012-12-12?18:00??微博test\微博test\bin\Debug\微博test.vshost.exe
?????文件???????1018??2012-11-27?08:59??微博test\微博test\bin\Debug\微博test.vshost.exe.config
?????文件????????490??2010-03-17?22:39??微博test\微博test\bin\Debug\微博test.vshost.exe.manifest
?????文件???????4802??2012-12-01?21:33??微博test\微博test\Form1.cs
?????文件???????5959??2012-12-01?20:39??微博test\微博test\Form1.Designer.cs
?????文件???????5817??2012-12-01?20:39??微博test\微博test\Form1.resx
?????文件???????8362??2012-12-12?17:50??微博test\微博test\Form2.cs
?????文件??????12956??2012-12-12?16:50??微博test\微博test\Form2.Designer.cs
?????文件???????5817??2012-12-12?16:50??微博test\微博test\Form2.resx
?????文件???????4680??2012-12-12?17:58??微博test\微博test\Form3.cs
?????文件???????4285??2012-12-11?18:28??微博test\微博test\Form3.Designer.cs
?????文件???????5817??2012-12-11?18:28??微博test\微博test\Form3.resx
?????文件???????2435??2012-12-12?17:58??微博test\微博test\Form4.cs
?????文件???????3631??2012-12-01?21:57??微博test\微博test\Form4.Designer.cs
?????文件???????5817??2012-12-01?21:57??微博test\微博test\Form4.resx
?????文件???????1367??2012-12-11?19:36??微博test\微博test\Form5.cs
?????文件???????3238??2012-12-11?19:19??微博test\微博test\Form5.Designer.cs
?????文件???????5817??2012-12-11?19:19??微博test\微博test\Form5.resx
?????文件???????5334??2012-12-12?17:51??微博test\微博test\Form6.cs
?????文件??????12201??2012-12-12?17:36??微博test\微博test\Form6.Designer.cs
?????文件???????6011??2012-12-12?17:36??微博test\微博test\Form6.resx
?????文件??????11317??2012-12-12?16:27??微博test\微博test\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件???????7767??2012-12-12?17:52??微博test\微博test\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件????????305??2012-11-26?18:10??微博test\微博test\obj\x86\Debug\edmxResourcesToem
?????文件????????249??2012-11-26?18:10??微博test\微博test\obj\x86\Debug\edmxResourcesToem
?????文件????????921??2012-11-26?18:10??微博test\微博test\obj\x86\Debug\edmxResourcesToem
............此處省略50個文件信息
- 上一篇:C#學生信息查詢系統
- 下一篇:強烈推薦:完整的C#源代碼之 網上商城購物系統
評論
共有 條評論