473,748 Members | 2,887 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# .NET OleDbConnection INSERT

1 New Member
Hello,
It's the first time that I program in C# with Visual Studio and I've got a problem,
I would like to know where is my error!

This is my code:
Expand|Select|Wrap|Line Numbers
  1. OleDbConnection conn = null;
  2.         private void button1_Click(object sender, EventArgs e)
  3.         {
  4.  
  5.  
  6.             try
  7.             {
  8.                 conn = new OleDbConnection("Provider=OraOLEDB.Oracle;"
  9.               + "Data Source=***********;"
  10.               + "User ID=**************;"
  11.               + "Password=***************;");
  12.                 conn.Open();
  13.  
  14.                 OleDbCommand cmd = new OleDbCommand("INSERT INTO user_mpl (Value1,Value2,Value3) VALUES (?,?,?);", conn);
  15.                 //OleDbParameter param1 = new OleDbParameter();
  16.                 //OleDbParameter param2 = new OleDbParameter();
  17.                 //param1.ParameterName = "@user";
  18.                 //param2.ParameterName = "@password";
  19.                 //param1.Value = textBox1.Text;
  20.                 //param2.Value = textBox2.Text;
  21.                 cmd.Parameters.Add("@Value1", OleDbType.Integer).Value =textBox3.Text;
  22.                 cmd.Parameters.Add("@Value2", OleDbType.VarChar, 10).Value = textBox2.Text;
  23.                 cmd.Parameters.Add("@Value3", OleDbType.VarChar, 10).Value =textBox1.Text;
  24.  
  25.  
  26.                 cmd.ExecuteNonQuery();
  27.  
  28.  
  29.             }
  30.             finally
  31.             {
  32.  
  33.                 conn.Close();
  34.             }
  35.  
  36.  }
  37.  
My message error is:
"Invalid Chararcter" for cmd.ExecuteNonQ uery();


Thanks for your Help

Sabine
Mar 21 '07 #1
1 3045
kenobewan
4,871 Recognized Expert Specialist
Welcome to the site. First check the input from your textboxes. Then see if that input matches the data type of your field design.
Mar 22 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2165
by: Job Lot | last post by:
I have written the following function which returns OleDbConnection object. If global variable g_strDbPath contains an invalid file name or path name the catch block throws an error with appropriate error message, but if g_strDbPath is blank then the catch block throws an error saying “No error information available: DB_SEC_E_AUTH_FAILED(0x80040E4D).” In this case connection string is incorrect so why doesn’t it throws as appropriate...
1
7240
by: Lilly | last post by:
Hi all. I'm really sorry for this post, I'm sure most of you will think it's a silly question, but the following doesn't work and I'm really new to ASP.NET: <%@ Page Language="C#" %> <%@ import Namespace="System.Data" %> <%@ import Namespace="System.Data.OleDb" %> <script runat="server">
1
6927
by: Matthias Kwiedor | last post by:
Hello! My Application is Multi-Threaded, where i have several threads which get datas and write them to the database, or have to read from the database to compare the datas and make updates if needed. The Database is MS Access. Connection String:
0
1937
by: Seth | last post by:
First off, my apologies if this is in the wrong newsgroup, but I hope I'm close enough. I'm trying to do some parsing of a CSV file using OleDbConnection, but for some reason, when I populate my DataSet, it is trimming the trailing spaces. Anybody know why? Here is my code: System.Data.OleDb.OleDbConnection connection = null;
0
1116
by: Tim | last post by:
I work on a dll with mfc support in C++ .NET. I include the following statemwents, but the complier does not allow me to do OleDbConnection * cnNwind = new OleDbConnection() The error msg says "OleDbConnection undeclared identifier Please help, thanks using namespace System using namespace System::Data
3
2028
by: COHENMARVIN | last post by:
I put the following code in my asp.net page: dbPath = MapPath("/FBDB/db1_newport2003.mdb") strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" strConnect = strConnect & "Data Source=" & dbpath & ";" objConnect = new OleDbConnection(strConnect) ============================= but I get the following error: <b>* Error while updating original data</b>.<br
1
1233
by: Souloron | last post by:
Here what I did: string cmdText = String.Format(("CREATE TABLE {0} (dno int primary key, Sunday char(5), Monday char(5), Tuesday char(5), Wednesday char(5), Thursday char(5), Friday char(5))"), tableName); OleDbConnection conn = new OleDbConnection(Form1.ConnectionString); conn.Open(); OleDbCommand cmd = new OleDbCommand(cmdText, conn); ...
16
7203
by: SyGC | last post by:
Hello, Im trying to connect to a MySQL DB on my home network (testing purposes) using the following VB.NET code; Imports System.Data.OleDb Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim SQLConnection As OleDbConnection
0
1504
by: MightyFeldar | last post by:
I've looked just about everywhere and pieced together as best as I can the code to update the tracking number in a CSV file for an order that has shipped out from our company so we can upload the file to our online shopping cart. I have 1 file with 3 columns that is an export from our shipping program, and the file that needs to be updated that we download from the shopping cart, insert the tracking numbers and re-upload. File 1:...
0
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9544
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9372
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9247
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8243
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4606
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.