VB数据库SQL语句学习_vb与sql数据库实例

2020-02-27 其他范文 下载本文

VB数据库SQL语句学习由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“vb与sql数据库实例”。

1.Select * from student查询所有原始记录

2.Select StudentID, StudentName from student 只查询学号和姓名

3.Select StudentID as 学号, StudentName as 姓名, Sex as 性别,Cla as 班级,NormalScore as 平时成绩,ExperimentScore as 实验成绩, ExaminationScore as 考试成绩 from student

4.Select * from student where sex=’男’只需要查看男生的成绩

5.Select * from student where NormalScore>80只需要查看平时成绩大于80分的记录

6.Select * from student where studentname like ‘陈%’查询姓陈的同学的记录

7.Select * from student order by examinationScore根据考试成绩排序

8.Select * from student order by examinationScore排序---降序

9.Select Sum(examinationScore)as 总成绩 from student求总成绩

10.Select Avg(examinationScore)as 平均成绩 from student求平均成绩

11.Select count(*)as 总记录数 from student求总记录数

12.Select Max(ExaminationScore)as 最高分 from student求最高分

13.Select Min(ExaminationScore)as 最高低分 from student求最低分

14.Select Cla as 班级, Avg(ExaminationScore)as 平均成绩 from student group by cla各班级成绩的分类汇总

Public Cla frmMain

Private ObjCnn As New OleDbConnection

Private ObjCmd As OleDbCommand

Private StrDir As String = “D:MIS1025StudentMgr.accdb”

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As

System.EventArgs)Handles MyBase.Load

ObjCnn.ConnectionString = “Provider=Microsoft.ACE.OLEDB.12.0;Data Source=” & StrDir

ObjCnn.Open()

ObjCmd = New OleDbCommand

ObjCmd.Connection = ObjCnn

End Sub

Private Sub FindRecord(ByVal StrSQL As String)

ObjCmd.CommandText = StrSQL

Dim rd As OleDbDataReader = ObjCmd.ExecuteReader

Dim tbl As New DataTable

tbl.Load(rd)

DataGridView1.DataSource = tbl

End Sub

Private Sub CmdFind_Click(ByVal sender As System.Object,System.EventArgs)Handles CmdFind.Click

FindRecord(txtSQL.Text)

End Sub ByVal e As

《VB数据库SQL语句学习.docx》
将本文的Word文档下载,方便收藏和打印
推荐度:
VB数据库SQL语句学习
点击下载文档
相关专题 vb与sql数据库实例 语句 数据库 vb vb与sql数据库实例 语句 数据库 vb
[其他范文]相关推荐
    [其他范文]热门文章
      下载全文