Click here to Skip to main content
15,888,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Posted
Updated 10-Jul-10 3:05am
v2

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.
 
Share this answer
 
Make sure you are connecting to the database correctly and that your connection remains open.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900