1.设置从Model中的Sub Main 启动

2.程序结构

3.Model1

Imports System.Windows.Forms.Application
Module Module1
Sub Main()
'form1 是测试多文档窗口
'Dim frm1 As New Form1()
'frm1.Show()
Dim formStudentSysMain As New FormStudentSysMain()
formStudentSysMain.Show()
Do While True
DoEvents()
Loop End Sub
End Module

4.FormStudentSysMain.vb

Imports System.Data.SqlClient
Public Class FormStudentSysMain
Public DBConnstr As String = "Data Source=LJJ-FF\LJJ;Initial Catalog=TestMvc;User ID=sa;Password=111111"
Private Sub quitMenuItem_Click(sender As Object, e As EventArgs) Handles quitMenuItem.Click
End
End Sub Private Sub selectinfoMenuItem_Click(sender As Object, e As EventArgs) Handles selectinfoMenuItem.Click
Dim formSearchStudent As New FormSearchStudent
formSearchStudent.MdiParent = Me
formSearchStudent.WindowState = FormWindowState.Normal
formSearchStudent.Show()
End Sub Private Sub updateinfoMenuItem1_Click(sender As Object, e As EventArgs) Handles updateinfoMenuItem1.Click
Dim formStudentInfo As New FormStudentInfo
FormSearchStudent.MdiParent = Me
FormSearchStudent.WindowState = FormWindowState.Normal
formStudentInfo.Show()
End Sub Private Sub importscoreMenuItem_Click(sender As Object, e As EventArgs) Handles importscoreMenuItem.Click
Dim formStudentCourse As New FormStudentCourse
FormSearchStudent.MdiParent = Me
FormSearchStudent.WindowState = FormWindowState.Normal
formStudentCourse.Show()
End Sub Private Sub cascadeMenuItem_Click(sender As Object, e As EventArgs) Handles cascadeMenuItem.Click
Me.LayoutMdi(MdiLayout.Cascade)
End Sub Private Sub horizonMenuItem_Click(sender As Object, e As EventArgs) Handles horizonMenuItem.Click
Me.LayoutMdi(MdiLayout.TileHorizontal)
End Sub Private Sub verticalMenuItem_Click(sender As Object, e As EventArgs) Handles verticalMenuItem.Click
Me.LayoutMdi(MdiLayout.TileVertical) End Sub Private Sub FormStudentSysMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub
End Class

5.FormSearchStudent.vb

Imports System.Data.SqlClient
Public Class FormSearchStudent Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim sqlConStr As String = My.Forms.FormStudentSysMain.DBConnstr
Dim sqlStr As String = "select * from student "
Dim sqlDataAdapter As New SqlDataAdapter
Dim dataSet As New DataSet
Dim sqlConnection As New SqlConnection(sqlConStr)
If Trim(txtName.Text) <> "" Then
sqlStr = sqlStr & "where name like '%" & Trim(txtName.Text) & "%'"
End If
sqlDataAdapter.SelectCommand = New SqlCommand(sqlStr, sqlConnection)
sqlConnection.Open()
sqlDataAdapter.Fill(dataSet)
sqlConnection.Close() DataGridView1.DataSource = dataSet.Tables() End Sub Private Sub FormSearchStudent_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub
End Class

6.运行结果

vb.net从数据库中取数据的更多相关文章

  1. 定时从远程的数据库中取数据,然后把取出来的数据插入或更新本地的oracle数据库的表

    最近项目中有一种需求: 大致需求是这样的 通过给定的 用户名和密码 要定时从远程的数据库中取数据,然后把取出来的数据插入或更新本地的oracle数据库的表 项目的结构式struts1 hibernat ...

  2. php从mysql数据库中取数据

    php从数据库中取数据  面向过程 <?php $server_name="localhost:3306"; //数据库服务器名称 $username="root& ...

  3. loadrunner 参数化-如何从数据库中取数据-连接数据库进行参数化

    LoadRunner提供两种参数化取值方式,一种是手动编辑,另一种就是通过连接数据库取值.一般在大型业务并发压力测试时,数据量肯定也都是非常大的,所以手动去编辑就不切实际了,这时用连接数据库的功能就方 ...

  4. JDBC:从数据库中取数据的一个bug

    先看错误信息: java.sql.SQLException: Before start of result set at com.mysql.jdbc.SQLError.createSQLExcept ...

  5. mybatis从数据库中取数据且分组,返回分组数据

    mapper.xml文件 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PU ...

  6. 从数据库中取数据(Stalberg.TMS.Data)

    using System; using System.Data; using System.Data.SqlClient; namespace Stalberg.TMS { //*********** ...

  7. Jmeter-从数据库中获取数据并作为变量传输

    再今天重新学习,从数据库中取数据,并作为变量传到下一个请求中. 首先第一步要导入mysql驱动包 一.添加JDBC Connection Configuration 设置链接 Database URL ...

  8. android从数据库中取音乐数据

    android从手机数据库中取音乐数据 直接贴代码 public void getMp3(){ list = new ArrayList<>(); Cursor mAudioCursor ...

  9. 多线程查询数据,将结果存入到redis中,最后批量从redis中取数据批量插入数据库中【我】

    多线程查询数据,将结果存入到redis中,最后批量从redis中取数据批量插入数据库中 package com.xxx.xx.reve.service; import java.util.ArrayL ...

随机推荐

  1. js -- 时间转年月日

    /** * 时间转年月日 * @param sdate 开始的时间 * @param edate 结束的时间 * @returns {*} */ function day2ymrStr2(sdate, ...

  2. 阿里巴巴手册之-Arrays.asList()数组转集合的问题

    转载来源:https://blog.csdn.net/qq_36443497/article/details/79663663?utm_source=blogxgwz9 在使用工具类Arrays.as ...

  3. 第三十篇 玩转数据结构——字典树(Trie)

          1.. Trie通常被称为"字典树"或"前缀树" Trie的形象化描述如下图: Trie的优势和适用场景 2.. 实现Trie 实现Trie的业务无 ...

  4. 题解 【洛谷P1035】[NOIP2002普及组]级数求和

    [NOIP2002普及组]级数求和 这个题……用循环也是可以的,不过我写了两种循环的题解,供各位dalao参考!O(∩_∩)O谢谢! for循环版本: #include<bits/stdc++. ...

  5. [lua]紫猫lua教程-命令宝典-L1-01-07. table表

    L1[table]01. table表的定义与赋值 小知识:声明表的例子 xx={}--创建一个空表xx --给这表的元素赋值 test="a" xx[test]="a& ...

  6. Go之第三方库ini

    文章转自 快速开始 my.ini # possible values : production, development app_mode = development [paths] # Path t ...

  7. vue 使用 jsonp 请求数据

    vue 使用 jsonp 请求数据 vue请求数据的时候,会遇到跨域问题,服务器为了保证信息的安全,对跨域请求进行拦截,因此,为了解决vue跨域请求问题,需要使用jsonp. 安装jsonp npm ...

  8. jquery grid 获取选中的行的数据,以及获取所有行的方法

    https://blog.csdn.net/shenqingkeji/article/details/52861319

  9. 虚拟函数是否应该被声明仅为private/protected?

    问题导入 我想对于大家来说,虚拟函数并不能算是个陌生的概念吧.至于怎么样使用它,大部分人都会告诉我:通过在子类中重写(override)基类中的虚拟函数,就可以达到OO中的一个重要特性——多态(pol ...

  10. C++转换构造函数和隐式转换函数

    今天是第一次听到C++还有个转换构造函数,之前经常见到默认构造函数.拷贝构造函数.析构函数,但是从没听说过转换构造函数,隐式转换函数也是一样,C++的确是够博大精深的,再次叹服!          其 ...