Exception.InnerException [英] Exception.InnerException

查看:130
本文介绍了Exception.InnerException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好...

我是vb2008的初学者.我需要用ms访问连接两种形式.第一个表单与第二个表单使用(form2.show)连接.我的需要是当我执行编码时.我在第一个表单上遇到错误创建表单时发生错误.有关详细信息,请参见Exception.InnerException.错误是:关闭对象时不允许进行操作."
我该如何解决这个问题..

并添加,更新,从数据库中删除..


这是我的代码:

这是第一种形式:

私有子Button1_Click(ByVal发送者为System.Object,ByVal e为System.EventArgs)处理Button1.Click
''将表单作为Form3昏暗


Form3.Show()

这是我的第二种形式:

昏暗的conn作为新的ADODB.Connection
昏暗的连接字符串
昏暗的数据库作为数据集
Dim instace As MissingSchemaAction
昏暗作为新的ADODB.Recordset
私人Sub Button2_Click(ByVal发送者为System.Object,ByVal e为System.EventArgs)句柄can.Click


Me.Close()
Form2.Close()

结束子

私有子Button1_Click(ByVal发送者为System.Object,ByVal e为System.EventArgs)处理Button1.Click
''关于错误恢复下一个

connectionString ="Provider = Microsoft.Jet.OLEDB.4.0;数据源= G:\ db1.mdb; Persist Security Info = False"
conn.Open(connectionString)

rs.Open(插入到table1(Name,Address,Contact_Number,vat)值("&snm.Text&"'',"&sadd.Text&'',"&Val(scno.Text )&,"&Val(svat.Text)&)",conn)

''rs.Open(''插入到table1(Id,Name,Address,Contact_Number,vat)值(``2'',``sam'',``abc street'',``22'','' 12''),conn)
rs =没什么
MsgBox(帐户已保存")
结束子

请帮助我..紧急


请帮我..
谢谢您.

Hello...

i''m very beginner in vb2008. i need to connect two forms with ms access. first form is connect with second using(form2.show). my need is when i execute the coding. i got a error on first form " An error occurred creating the form. See Exception.InnerException for details. The error is: Operation is not allowed when the object is closed. "
How can i solve the issue..

and also add,update, delete from database..


This is my codes:

this is first form:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
''Dim form As Form3


Form3.Show()

this is my second form:

Dim conn As New ADODB.Connection
Dim connectionString
Dim DB As DataSet
Dim instace As MissingSchemaAction
Dim rs As New ADODB.Recordset
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles can.Click


Me.Close()
Form2.Close()

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
''On Error Resume Next

connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\db1.mdb;Persist Security Info=False"
conn.Open(connectionString)

rs.Open("insert into table1(Name,Address,Contact_Number,vat) values (''" & snm.Text & "'',''" & sadd.Text & "''," & Val(scno.Text) & " , " & Val(svat.Text) & ")", conn)

''rs.Open("insert into table1(Id,Name,Address,Contact_Number,vat) values (''2'',''sam'',''abc street'',''22'',''12'')", conn)
rs = Nothing
MsgBox("account saved")
End Sub

help me plz.. urgent


Plz help me..
thank you

推荐答案

没有人不会看到您的代码就无法为您提供答案.您甚至没有告诉我们关闭对象时"指的是什么.什么东西您是否在不先打开连接的情况下执行数据库操作?我们需要查看引发错误的代码,否则我们将无能为力.
No one is going to be able to provide you with an answer without seeing your code. You haven''t even told us what "when the object is closed" is referring to. What object? Are you doing a database operation without opening the connection first? We need to see the code where the error was thrown or we can''t help.


确保您正确连接到数据库并且连接保持打开状态.
Make sure you are connecting to the database correctly and that your connection remains open.


这篇关于Exception.InnerException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆