Windowsmobile使用多种形式,到单个数据库 [英] windowsmobile-use multiple form, to single database
问题描述
你好....我将在我的smartdevice项目中使用2个表单和单个数据库创建查询.第一种形式用于输入数据,第二种形式用于使用datagrid的视图数据.我正在使用vs 2008,C#,Framework 2.0,Windowsmobile 5 ....我该怎么办?我需要一个示例查询和代码
hello....i will create query using 2 form and single database in my smartdevice project. the first form for input data, and the second form for view data using datagrid. i am using vs 2008, c#, framework 2.0, windowsmobile 5.....what can i do????...can any body help me how i can do it????? i need a sample query and code
推荐答案
这是我在form1中的代码:
使用系统;
使用System.Linq;
使用System.Collections.Generic;
使用System.ComponentModel;
使用System.Data;
使用System.Drawing;
使用System.Text;
使用System.Windows.Forms;
使用System.Data.SqlServerCe;
命名空间FirstSmartDeviceProject
{
公共局部类Form1:Form
{
公共Form1()
{
InitializeComponent();
}
/*重置按钮代码*/
私有无效btnreset_Click(对象发送者,EventArgs e)
{
txtuname.Text =";
txtpassword.Text =";
}
私有无效btnlogin_Click(对象发送者,EventArgs e)
{
AppDatabase1DataSet ds =新的AppDatabase1DataSet();
AppDatabase1DataSet.userDataTable dt =新的AppDatabase1DataSet.userDataTable();
this.userTableAdapter1.Fill(dt);
foreach(在dt.rows中的DataRow dr)
{
if(dr [1] .ToString()== txtuname.Text&& dr [2] .ToString()== txtpassword.Text)
{
txtpassword.Text =";
txtpassword.Text = dr [0] .ToString();
MessageBox.Show(登录有效!");
}
}
}
私有无效nextbtn_Click(对象发送者,EventArgs e)
{
表单名称=新的Form2(); Name.Show();
}
}
}
这是我在form2中的代码:
this is my code in form1:
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlServerCe;
namespace FirstSmartDeviceProject
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
/* Reset Button Code */
private void btnreset_Click(object sender, EventArgs e)
{
txtuname.Text = "";
txtpassword.Text = "";
}
private void btnlogin_Click(object sender, EventArgs e)
{
AppDatabase1DataSet ds = new AppDatabase1DataSet();
AppDatabase1DataSet.userDataTable dt = new AppDatabase1DataSet.userDataTable();
this.userTableAdapter1.Fill(dt);
foreach (DataRow dr in dt.Rows)
{
if (dr[1].ToString() == txtuname.Text && dr[2].ToString() == txtpassword.Text)
{
txtpassword.Text = "";
txtpassword.Text = dr[0].ToString();
MessageBox.Show("Login Valid!");
}
}
}
private void nextbtn_Click(object sender, EventArgs e)
{
Form Name = new Form2(); Name.Show();
}
}
}
and this is my code in form2:
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace FirstSmartDeviceProject
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
if (AppDatabase1DataSet2Util.DesignerUtil.IsRunTime())
{
// TODO: Delete this line of code to remove the default AutoFill for 'appDatabase1DataSet2.user'.
this.userTableAdapter.Fill(this.appDatabase1DataSet2.user);
}
}
private void backbtn_Click(object sender, EventArgs e)
{
Form Name = new Form1(); Name.Show();
}
}
}
我想在form1中将数据textboxt插入到form2中的datagridview中,并保存它.但是,如果我部署该代码,则form1中的文本框无法插入到datagridview form2中
....谁能帮助我....我是开发智能设备的初学者
i want to insert data textboxt in form1 to datagridview in form2, and save it. but if i deploy that code, textbox in form1 cannot insert in datagridview form2
....can any body help me....i am a beginner to development smartdevice
这篇关于Windowsmobile使用多种形式,到单个数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!