By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,312 Members | 1,309 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,312 IT Pros & Developers. It's quick & easy.

Problem on INSERTING a record to database using typed datasets

P: n/a
Dear All,
I have problem on inserting a record to database..Although it looked
easy.. i have caught up with following issue .. please go ahead and
help me to find solution

I Need to insert records to a data base,for which i am using Typed
dataSet.(I used DataSet Designer to create one)
Then created a table adapter in which i have written query for
INSERT , & set Database Direct property to true.(I didnt use a
seperate methods for INSERT,instead used inbuilt )

query......>INSERT INTO TABLE1 (NAME,CITY) VALUES (?,?)

Then in My .Vb file i called this method as
Adapter1.Insert("Value1",Value2").. before that
i used Adapter1.connection.open() and Adapter1.connection.close after
that insert ., explicitly.
For the Insert button coding...

Although it compiles and executes Fine .. record is not inserted.to
database Please clarify what I have been missing

I am using Visual studio 2005 & Access 2003

Thanks in advance,

Surya

Sep 22 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
This issue may have to do with the way you set up your Access data source.

See the article at:

http://getdotnetco.web119.discountas...ccessPart1.htm

In the article see item 'z.' that discusses the MDB property 'Copy to Output
Directory'.

--
Mike

Mike McIntyre [MVP]
http://www.getdotnetcode.com
"Surya" <su*************@gmail.comwrote in message
news:11**********************@y42g2000hsy.googlegr oups.com...
Dear All,
I have problem on inserting a record to database..Although it looked
easy.. i have caught up with following issue .. please go ahead and
help me to find solution

I Need to insert records to a data base,for which i am using Typed
dataSet.(I used DataSet Designer to create one)
Then created a table adapter in which i have written query for
INSERT , & set Database Direct property to true.(I didnt use a
seperate methods for INSERT,instead used inbuilt )

query......>INSERT INTO TABLE1 (NAME,CITY) VALUES (?,?)

Then in My .Vb file i called this method as
Adapter1.Insert("Value1",Value2").. before that
i used Adapter1.connection.open() and Adapter1.connection.close after
that insert ., explicitly.
For the Insert button coding...

Although it compiles and executes Fine .. record is not inserted.to
database Please clarify what I have been missing

I am using Visual studio 2005 & Access 2003

Thanks in advance,

Surya

Sep 22 '07 #2

P: n/a
Surya,

I don't see you using the DataAdapter.Update command, am I right or did you
not show it?

Cor

"Surya" <su*************@gmail.comschreef in bericht
news:11**********************@y42g2000hsy.googlegr oups.com...
Dear All,
I have problem on inserting a record to database..Although it looked
easy.. i have caught up with following issue .. please go ahead and
help me to find solution

I Need to insert records to a data base,for which i am using Typed
dataSet.(I used DataSet Designer to create one)
Then created a table adapter in which i have written query for
INSERT , & set Database Direct property to true.(I didnt use a
seperate methods for INSERT,instead used inbuilt )

query......>INSERT INTO TABLE1 (NAME,CITY) VALUES (?,?)

Then in My .Vb file i called this method as
Adapter1.Insert("Value1",Value2").. before that
i used Adapter1.connection.open() and Adapter1.connection.close after
that insert ., explicitly.
For the Insert button coding...

Although it compiles and executes Fine .. record is not inserted.to
database Please clarify what I have been missing

I am using Visual studio 2005 & Access 2003

Thanks in advance,

Surya
Sep 22 '07 #3

P: n/a
Hi Mike,Cor
Thanks for spending your time on me.. I had found where i was wrong &
your suggestions were useful, also got idea from another forum ,

Cor , I was using Insert method generated from table adapter
directly(& i set Generate DBDirect Property to true) so no need of
using update command while Inserting

Actual problem was ------I was inserting data to local file & not to
the original database file
Normally when we add a table adapter through DataSet designer in VS
2005 it prompts "Local database file dialog box" at the end ..

Following link helped me

http://msdn2.microsoft.com/en-us/library/ms246989.aspx

Excerpts from the link :

To respond to the Local database file dialog box

Click Yes if you want Visual Studio to copy the database file into
your project and modify the connection to point to the copy in your
project. For more information on working with database files in your
project, see Local Data Overview.

Click No if you do not want Visual Studio to copy the database file
into your project. Instead, the connection points to the file in the
original location.

Thank you,
Surya

Sep 23 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.