Re: Newbie - Creating ms access table from Visual Basic
From: Val Mazur (group51a_at_hotmail.com)
Date: 08/19/04
- Next message: Tyler Hudson: "Coding a client/server app with flexibility for future port to 3-tier"
- Previous message: Val Mazur: "Re: Get table and field names"
- In reply to: Bikrant Neupane: "Re: Newbie - Creating ms access table from Visual Basic"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 19 Aug 2004 18:18:31 -0400
Hi,
This is one more reason to use ADO library directly instead of control,
because in your case you do not need it. Each control will open its own
connection, but it will be opened only in a case if your Data control
returns some data, like SELECT SQL statement. If you do not want to use ADO
library, then you could check connection of the recordset using next kind of
code
if Not Adodc1.Recordset Is Nothing then
if Adodc1.Recordset.ActiveConnection.State=adStateOpen then
'you have an opened connection
endif
endif
-- Val Mazur Microsoft MVP "Bikrant Neupane" <bikrant_ml@wlink.com.np> wrote in message news:ehurUdOhEHA.3016@tk2msftngp13.phx.gbl... > Val Mazur wrote: >> Hi, >> >> I believe it is not enough. CREATE TABLE belongs to the Data Definition >> language and it does not select any data. That means you cannot use it to >> open recordset (what you are trying to do in your code). Instead you need >> to use >> Execute method of ADO Connection or command to execute this statement, >> not Open method of the recordset and option should be adCmdText, not >> adCmdTable >> >> MyConnection.Execute sqlCreateTable, , adCmdText >> > > Hi, > I have tried this: sqlCreateTable = " Create table record ( colour > text(15) )" > Adodc1.Recordset.Source = sqlCreateTable > Adodc1.Recordset.Open > > and it did work for me. The command did get executed, however the > connection was not open. Instead I again did: > > Adodc1.Recordset.Source = "Select * from record" > Adodc1.Recordset.Open > > and now I can use the connection. > > Also,next problem,I have not been able to test if a connection is already > open or closed. If i try to close already closed connection then I get an > error. How do i test if a connection is open or closed?? > > Thanks, > Bikrant > >
- Next message: Tyler Hudson: "Coding a client/server app with flexibility for future port to 3-tier"
- Previous message: Val Mazur: "Re: Get table and field names"
- In reply to: Bikrant Neupane: "Re: Newbie - Creating ms access table from Visual Basic"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|