关于vb.net删除实例的信息
vb.net 类实例的销毁
无代码无真相!
站在用户的角度思考问题,与客户深入沟通,找到白山网站设计与白山网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:成都网站制作、成都网站设计、企业官网、英文网站、手机端网站、网站推广、域名注册、网站空间、企业邮箱。业务覆盖白山地区。
话说,应该看你这个实例a是作用域的变量,如果仅仅是在函数A中定义的局部变量,那么应该会在函数运行完成的时候自动销毁的。这个应该是变量的生存期问题。
但是,根据你所提供的描述来看,你的这个a类应该定义的至少是一个是模块级别的变量,不然,你在函数B中,用另一个b类来引用a实例是无法实现的。因此,我感觉函数A运行完了之后,你的a实例应该并没有销毁,只有等到整个模块被结束的时候才能销毁。
(PS: VB.net没有用过,以上仅仅是基于vb6.0的类模块使用方法所提出的一点参考建议!)
求 vb.net winform datagridview checkbox多行删除实例
'批量删除信息
Dim flag As Boolean = False '标识是否删除成功
For index = 0 To DataGridView1.Rows.Count - 1
If dgDataGridView1tem("控件名称", index).Value=true Then
Dim orderId As Integer = Integer.Parse(DataGridView1.Item("列名", index).Value)
'调用删除方法
If 类.方法名() Then
flag=True
End If
End If
Next
if flag=true then
messagebox.show("删除成功!")
else
messagebox.show("删除失败!")
当然:类.方法名() 这个方法返回一个布尔值,呵呵,也可以是其它类型,到时候可要变哦
VB.net怎样全部删除DataGridView的内容?
方法有多种。
可以dataAdapter.Fill到数据表应该,设置几个command,再通过dataAdapter.Update就可以更新数据了。不过表要有一个关键的key吧。
另外一种直观一点:
也需要表有个关键key有就是关键字段。
你datagridview.reomveAt(index)同时执行sqlcommand("delete * From table where keyFild='" key "'")就可以。
参考一个实例,如下:
Private Sub bitDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bitDelete.Click
Dim oraConn As New OracleConnection()
oraConn.ConnectionString = " data source=数据库名字;user id=账号;password=密码"
oraConn.Open()
Dim id As String = DataGridView1.CurrentRow.Cells(0).Value.ToString().Trim()
Dim queryString = "delete from t where id ='" id号 "'"
Dim adapter As OracleDataAdapter = New OracleDataAdapter(queryString,oraConn)
Dim mark As DataSet = New DataSet
adapter.Fill(mark, "Mark")
MessageBox.Show("删除数据成功!")
Dim adapter As OracleDataAdapter = New OracleDataAdapter("select * from t ORDER BY id", oraConn)
Dim score As DataSet = New DataSet()
adapter.Fill(score , "Score ")
DataGridView1.DataSource = score
DataGridView1.DataMember = score .Tables(0).ToString
oraConn.Close()
End Sub
求一个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) '按指定sql,反馈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语句执行前,必须打开连接
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语句失败!" Str_sql)
Fun_sql1 = False
End Try
End Function
Function Fun_sqln(Str_sql As String, V_调用来源 As String) '按指定sql,反馈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语句失败!" 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 注册表删除操作 郁闷中……
这不是废话吗,DeleteSubKey只能删除调用实例的子项,并不能直接删除子子项。
本文名称:关于vb.net删除实例的信息
网页路径:http://ybzwz.com/article/dsgjhpd.html