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. python面试的100题(2)

    def print_directory_contents(sPath): """ 这个函数接收文件夹的名称作为输入参数 返回该文件夹中文件的路径 以及其包含文件夹中文件的 ...

  2. spring(四):Resource

    Resource Spring的Resource接口代表底层外部资源,提供了对底层外部资源的一致性访问接口. public interface Resource extends InputStream ...

  3. 题解【洛谷P2513/CJOJ1345】[HAOI2009]逆序对数列

    P1345 - [HAOI2009]逆序对数列 Description 对于一个数列{ai},如果有i<j且ai>aj,那么我们称ai与aj为一对逆序对数.若对于任意一个由1~n自然数组成 ...

  4. 关于BaiduPSC-Go的一些bug的更正

    首先说下操作步骤 下载是在GutHub,这个不赘述,网上很多资料 下载之后配置环境变量,在path的后面加上一个分号,然后加上你下载的目录,目录名最好为英文 然后通过命令行CMD工具,输入BaiduP ...

  5. 【资源分享】Garry's mod 自制整合包

    *----------------------------------------------[下载区]----------------------------------------------* ...

  6. alert警告框点击确定后自动提交表单

    转载于  :https://zhidao.baidu.com/question/619375120140398412.html 在页面中有多个input type="text"的文 ...

  7. 一些常用的js代码

    跳转 window.location.href= 刷新  location.reload()

  8. ($children,$refs,$parent)的使用

    如果项目很大,组件很多,怎么样才能准确的.快速的寻找到我们想要的组件了?? $refs 首先你的给子组件做标记.demo :<firstchild ref="one"> ...

  9. 【资源分享】Dll Injector(DLL注入器)

    *----------------------------------------------[下载区]----------------------------------------------* ...

  10. python面向对象封装案例2

    封装 封装 是面向对象编程的一大特点 面向对象编程的 第一步 —— 将 属性 和 方法 封装 到一个抽象的 类 中 外界 使用 类 创建 对象,然后 让对象调用方法 对象方法的细节 都被 封装 在 类 ...