473,382 Members | 1,165 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Executing an insert Command from the Connection object

Hello,
i have a project where every time i want to add or update
something in the DB i use the datatable and dataadpter
and i build an insert sql command or an update sql
command to the dataadapter and then use the update.
i want to know if i can execute the command i make
directly through the connection object (oledb) and not
create the datatable and dataadapter
thank u
Nov 15 '05 #1
2 1740
Sam
You don't have to use a datatable and dataadapter but you
do need more than just the OleDbConnection object. You
could try using the OleDbCommand object instead.

// -- Start Code Example
string ConnectionString
= "Provider=Microsoft.Jet ..etc..";
OleDbConnection conn = new OleDbConnection
(ConnectionString);
OleDbCommand comm = new OleDbCommand();
comm.CommandText = "INSERT INTO ..etc..";
comm.Connection = conn;
conn.Open();
comm.ExecuteNonQuery();
conn.Close();
// -- End Code Example
HTH

Sam
-----Original Message-----
Hello,
i have a project where every time i want to add or updatesomething in the DB i use the datatable and dataadpter
and i build an insert sql command or an update sql
command to the dataadapter and then use the update.
i want to know if i can execute the command i make
directly through the connection object (oledb) and not
create the datatable and dataadapter
thank u
.

Nov 15 '05 #2
Hi,

You can execute DML statements without having to create
datatable and dataadapter. You can create the
OleDbCommand/SqlCommand object based on the database and
execute the command.

DataAdapter is basically used to fill the dataset and
update the database based on the changes which are done
to the dataset.

The following link explains of how to work with command
object.

http://samples.gotdotnet.com/quickst...o/doc/adoplus/
ExecuteCommand.aspx

Regards,
Madhu

MVP | MCSD.NET
-----Original Message-----
Hello,
i have a project where every time i want to add or updatesomething in the DB i use the datatable and dataadpter
and i build an insert sql command or an update sql
command to the dataadapter and then use the update.
i want to know if i can execute the command i make
directly through the connection object (oledb) and not
create the datatable and dataadapter
thank u
.

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Brian | last post by:
hi, when i want to do an action to the database i am using the command Set myConn = Server.CreateObject("ADODB.Connection") myConn.Open = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &...
10
by: Mike | last post by:
I know this sounds strange but I am at a loss. I am calling a simple funtion that opens a connection to a SQL Server 2000 database and executes an Insert Statement. private void...
3
by: alexmaster_2004 | last post by:
hi i have made an application using C# that access sql2000. this application is just used to insert data to the database. i use something like this in my code: // string colmnA = TextBox1.Text;...
1
by: nicholas | last post by:
To insert a record in a Ms Access database and be able to retrieve the newly created ID (autonumber) I used the code below (code 1). Now, the problem is that this is not very secure and that, if...
0
by: Eustice Scrubb | last post by:
In line coding problem. Here's my code: <script language="VB" runat="server"> Dim myConnection As SqlConnection Sub Page_Load(Src As Object, e As EventArgs) ' Create a connection to the SQL...
7
by: Kevin Lawrence | last post by:
Hi all I want to do "INSERT INTO Table (Blob) Values('blobdataasstring')". ...rather than using the parameter driven method, is it possible? And if so what encoder do I use to convert the...
8
by: Martin Z | last post by:
INSERT INTO dbo.Transmission (TransmissionDate, TransmissionDirection, Filename, TransmittedData) VALUES (@TransmissionDate,@TransmissionDirection,@Filename,@TransmittedData); SELECT @retVal =...
13
by: Terry Olsen | last post by:
I'm using OleDb to connect with an Access Database. I have anywhere from 10 to over 100 records that I need to either INSERT if the PK doesn't exist or UPDATE if the PK does exist, all in a single...
7
by: anu b | last post by:
Hi I need to use Clr trigger for insert command My code is as below I am using SQL server 2005 and VS 2008.... but after running this code i didnt get the result as i expexted it shows the...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.