473,387 Members | 1,903 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,387 software developers and data experts.

OleDb MsAccess Insert

public void insert_data()
{
string source = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\\sc.mdb";
string command1 = string.Format("select count(*) from Fourn where
NoFourn = {0}", Int64.Parse(textBox1.Text));
string command2 = string.Format("insert into Fourn
(NoFourn,NomFourn,TelFourn) values({0},'{1}',{2})",
Int64.Parse(textBox1.Text), textBox2.Text,
Int64.Parse(textBox3.Text));
string command3 = string.Format("update from Fourn set
NomFourn='Michel' where NoFourn=15");
OleDbCommand iCommand = new OleDbCommand();
OleDbConnection iConnection = new OleDbConnection(source);

{
iConnection.Open();

iCommand.Connection = iConnection;
iCommand.CommandText=command1;
OleDbDataReader iReader1;

iReader1 = iCommand.ExecuteReader();
iReader1.Read();

{
if(iReader1.GetInt32(0) != 0)
{
iReader1.Close();
iCommand.CommandText=command3;
MessageBox.Show("Deja Existant");
iReader1.Close();
iConnection.Close();
}
else
{
iReader1.Close();
iCommand.CommandText=command2;
textBox1.Text="";
textBox2.Text="Cfait";
textBox3.Text="";
iConnection.Close();
}

}

}
Nov 15 '05 #1
0 1114

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

Similar topics

2
by: Joe | last post by:
Hi All, I am new to using the Access DB and I need some help if someone is able to give it to me. What I want to do is get the names of the columns of certain tables. Not the data in the table...
2
by: Michel R. | last post by:
What`s wrong with this ??? The insert does not add into the database. Using a Winform and Database is sc.mdb Filename is supplier Fields SuppNbr Int64 SuppName String SuppPhone Int64...
1
by: Brian Henry | last post by:
I have an access database, and one of the fields in the table I am inserting into has a date/time data type. What is the correct OleDb data type to insert the date and time that it is at the moment...
0
by: NicK chlam via DotNetMonster.com | last post by:
this is the error i get System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. at System.Data.Common.DbDataAdapter.Update(DataRow dataRows, DataTableMapping tableMapping) at...
1
by: Joe | last post by:
Hello All, I am trying to insert a record in the MS Access DB and for some reason I cannot get rid of error message, System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. ...
1
by: vivek g | last post by:
System.Data.OleDb.OleDbException -------------------------------------------------------------------------------- Hi All,I am getting problem while accessing the MSAccess database.The error I...
5
by: mabond | last post by:
Hi VB.NET 2005 Express edition Microsoft Access 2000 (SP-3) Having trouble writing an "insert into" command for a Microsoft table I'm accessing through oledb. I've tried to follow the same...
1
by: vikramrawal | last post by:
hi, I am using C# with MSAccess XP. I need to insert bulk of records around 10000 in MSAccess. So obviously if I inserts each record individually then it will take lot of time. By using...
0
by: mwenz | last post by:
I am trying to update an Access table using OLEDB in VB.Net 2005. I can add rows but I cannot update them. Code to instantiate the Access database and table... Dim conn As New...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.