Connecting Tech Pros Worldwide Forums | Help | Site Map

Problem on INSERTING a record to database using typed datasets

Surya
Guest
 
Posts: n/a
#1: Sep 22 '07
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


Mike McIntyre
Guest
 
Posts: n/a
#2: Sep 22 '07

re: Problem on INSERTING a record to database using typed datasets


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" <suryaprakash.g2@gmail.comwrote in message
news:1190446946.762018.281500@y42g2000hsy.googlegr oups.com...
Quote:
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
>

Cor Ligthert[MVP]
Guest
 
Posts: n/a
#3: Sep 22 '07

re: Problem on INSERTING a record to database using typed datasets


Surya,

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

Cor

"Surya" <suryaprakash.g2@gmail.comschreef in bericht
news:1190446946.762018.281500@y42g2000hsy.googlegr oups.com...
Quote:
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
>
Surya
Guest
 
Posts: n/a
#4: Sep 23 '07

re: Problem on INSERTING a record to database using typed datasets


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

Closed Thread