包含vb.net实例大全的词条

求一个VB.net 增删改查实例 ,哪位大神有空帮我写一下或者有现成的给我一个,,我比较菜又比较急 , 在线等Imports System.Data.OleDb
'Imports System.Data.OracleClient
Imports System.Data.SqlClient
'链接Oracle
'cn = New SqlConnection(""Data Source=TNS名称;Persist Security Info=True;User ID=用户名;Password=密码;" ")
'Imports System.Data.OracleClient
'Dim oOracleConn As OracleConnection = New OracleConnection()
'oOracleConn.ConnectionString = ""Data Source=MyOracleDB; User Id=username; Password=passwd; Integrated Security=no; "
'oOracleConn.Open()
'链接SQL Server
'cn = New SqlConnection("Data Source=.;Initial Catalog=Sales;Integrated Security=False;User ID=sa;Password=;")
'链接Access
'cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="db_path";Persist Security Info=False")
Public Class Fun_DataBase
Dim cn As OleDbConnection
Dim cm As OleDbCommand
Dim da As OleDbDataAdapter
Dim ds As DataSet
Dim db_path As String = "D:\Documents\Visual Studio 2013\Projects\VBnet1\VBnet1\Resources\Database1.mdb"
Function Fun_sql1(Str_sql As String, V_调用来源 As String)'按指定sqlvb.net实例大全 , 反馈1个查询值
Try
'Dim cn As New OleDbConnection("Data Source=.;Initial Catalog=Sales;Integrated Security=False;User ID=sa;Password=123456;")
'链接Access
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="db_path";Persist Security Info=False")
cn.Open() 'sql语句执行前vb.net实例大全,必须打开连接
cm = New OleDbCommand(Str_sql, cn)
cm.ExecuteNonQuery()
Dim strValue As String = cm.ExecuteScalar.ToString
'MessageBox.Show(strValue)
Fun_sql1 = strValue
cn.Close()
Fun_sql1 = True
Catch ex As Exception
MessageBox.Show(V_调用来源":执行sql语句失败vb.net实例大全!"Str_sql)
Fun_sql1 = False
End Try
End Function
Function Fun_sqln(Str_sql As String, V_调用来源 As String) '按指定sqlvb.net实例大全,反馈1行n列查询值
Try
'链接Access
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="db_path";Persist Security Info=False")
cn.Open() 'sql语句执行前,必须打开连接
Dim cmd As New OleDbCommand("select * from grade", cn)
'Dim dr As SqlDataReader
Dim dr As OleDbDataReader
dr = cmd.ExecuteReader()
Dim strDisplay As String = ""
While dr.Read()
Fun_sqln = dr(0).ToString"|"
End While
cn.Close()
Fun_sqln = True
Catch ex As Exception
MessageBox.Show(V_调用来源":执行sql语句失败vb.net实例大全!"Str_sql)
Fun_sqln = False
End Try
'Dim s = Split(F.Fun_sqln("ef"), "|")
'Dim i As Integer
'i = UBound(s)
'For i = 0 To UBound(s)
'MessageBox.Show(s(i))
'Next
End Function
Public Function Fun_sql_exec(Str_sql As String, V_调用来源 As String) '执行指定sql , 反馈T|F
Try
'链接Access
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="db_path";Persist Security Info=False")
cn.Open() 'sql语句执行前,必须打开连接
cm = New OleDbCommand(Str_sql, cn)
cm.ExecuteNonQuery()
cn.Close()
Fun_sql_exec = True
Catch ex As Exception
MessageBox.Show(V_调用来源":执行sql语句失败!"Str_sql)
Fun_sql_exec = False
End Try
End Function
VB.net实例1 生成txt文件 。
DimSaveFileDialog1AsNewSaveFileDialog() '创建一个保存对话框
SaveFileDialog1.Filter ="txt files (*.txt)|*.txt" '设置扩展名
IfSaveFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OKThen '如果确定保存
My.Computer.FileSystem.WriteAllText(SaveFileDialog1.Filename, Textbox1.Text,False) '保存文本,False表示不追加文本,直接覆盖其内容

推荐阅读