标题:oledbDatareader的语句是怎样的?
只看楼主
zhlxh1201
Rank: 1
等 级:新手上路
帖 子:118
专家分:0
注 册:2007-3-30
 问题点数:0 回复次数:17 
oledbDatareader的语句是怎样的?
oledbDatareader的语句是怎样的?
搜索更多相关主题的帖子: 语句 
2007-04-13 09:53
liuminghui
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:2882
专家分:0
注 册:2007-1-26
得分:0 
不要急  马上发给你

海鸽 is My Lover!!
2007-04-13 09:56
liuminghui
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:2882
专家分:0
注 册:2007-1-26
得分:0 

先看两段程序



//添加数据到数据库中
private void button1_Click(object sender, EventArgs e)//添加信息
{
// try
//{
DataSet ds = new DataSet();

OleDbConnection conn = new OleDbConnection("Data Source=F:\\c#.net\\学生信息管理\\denglu.mdb;provider=Microsoft.Jet.OLEDB.4.0");
OleDbDataAdapter daAuthors = new OleDbDataAdapter("Select * From Teacher ", conn);


conn.Open();
oleDbInsertCommand1.Connection = conn;
daAuthors.InsertCommand = oleDbInsertCommand1;

oleDbInsertCommand1.CommandText = "Insert into Teacher(Depart,Grade,clas,Curriculum,Teacher) values( '" + this.comboBox1.Text + " ' ,'" + @comboBox2.Text + "',' " + @comboBox3.Text + " ',' " + @comboBox4.Text + " ',' " + textBox1.Text + " ')";

string s = "Insert into Teacher (Depart,Grade,clas,Curriculum,Teacher) values( '" + this.comboBox1.Text + " ' ,'" + @comboBox2.Text + "',' " + @comboBox3.Text + " ',' " + @comboBox4.Text + " ',' " + textBox1.Text + " ')";
MessageBox.Show(s);
daAuthors.InsertCommand.ExecuteNonQuery();


daAuthors.Fill(ds, "denglu");
dataGrid1.DataSource = ds.Tables[0];
conn.Close();
//}
// catch (Exception ex)
//{
// MessageBox.Show(ex.Message);
//}

}






//修改数据

private void button2_Click(object sender, EventArgs e)//修改信息
{
DataSet ds = new DataSet();

OleDbConnection conn = new OleDbConnection("Data Source=F:\\c#.net\\学生信息管理\\denglu.mdb;provider=Microsoft.Jet.OLEDB.4.0");
OleDbDataAdapter daAuthors = new OleDbDataAdapter("Select * From Teacher ", conn);
string myID = dataGrid1[dataGrid1.CurrentCell.RowNumber, 0].ToString().Trim();

conn.Open();
oleDbUpdateCommand1.Connection = conn;
daAuthors.UpdateCommand = oleDbUpdateCommand1;

oleDbUpdateCommand1.CommandText = "Update Teacher set Depart='" + this.textBox1.Text + " ' ,Grade='" + @textBox2.Text + "',clas=' " + @textBox3.Text + " ',Curriculum=' " + @textBox4.Text + " ',Teacher=' " + @textBox5.Text + " ' where ID= "+ int.Parse(myID);


daAuthors.UpdateCommand.ExecuteNonQuery();


daAuthors.Fill(ds, "denglu");
dataGrid1.DataSource = ds.Tables[0];
conn.Close();
}

[此贴子已经被作者于2007-4-13 10:00:52编辑过]


海鸽 is My Lover!!
2007-04-13 10:00
bygg
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:乖乖的心中
等 级:版主
威 望:241
帖 子:13555
专家分:3076
注 册:2006-10-23
得分:0 
你想实现什么?

飘过~~
2007-04-13 10:01
Kendy123456
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:62
帖 子:2720
专家分:0
注 册:2007-1-3
得分:0 
想实现读取数据库呗

2007-04-13 10:02
liuminghui
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:2882
专家分:0
注 册:2007-1-26
得分:0 
不是我想实现什么 是楼主要OleDbConnection的方面的知识的,所以我先给她看看怎么用的

然后再告诉她OleDbConnection方面的理论知识

海鸽 is My Lover!!
2007-04-13 10:03
zhlxh1201
Rank: 1
等 级:新手上路
帖 子:118
专家分:0
注 册:2007-3-30
得分:0 

我的语句:
Dim conn As System.Data.OleDb.OleDbConnection
Dim sStr As String
Dim dr As System.Data.OleDb.OleDbDataReader
???????

sStr = "Provider=MSDAORA.1;pwd=pwd;user id=username;datas ource=kksb"
conn = New System.Data.OleDb.OleDbConnection(sStr)
conn.Open()
sStr = "select * from t_user where username='" & username.Text & "' and pwd='" & pwd.text & "'"
问号部分不会


不求尽如人意,但求无愧我心!
2007-04-13 10:03
liuminghui
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:2882
专家分:0
注 册:2007-1-26
得分:0 
让你们见笑了吧

海鸽 is My Lover!!
2007-04-13 10:03
zhlxh1201
Rank: 1
等 级:新手上路
帖 子:118
专家分:0
注 册:2007-3-30
得分:0 
只是为了读取数据

不求尽如人意,但求无愧我心!
2007-04-13 10:05
zhlxh1201
Rank: 1
等 级:新手上路
帖 子:118
专家分:0
注 册:2007-3-30
得分:0 
大家看看我的代码
帮我看看

不求尽如人意,但求无愧我心!
2007-04-13 10:09



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-131497-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.096042 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved