hello every body
when iam trying to delete the last record in DGV this erro appears
"Input string was not in a correct format."
this error appears only when i am trying to delete the last record.
.
the code i using is the following - public void Delete(int id)
-
{
-
////////////Delete the record from the dataset.///////////
-
DataRow[] DR = dttel.Select("id=" + id + "");
-
DR[0].Delete();
-
}
-
-
-
-
-
public void UpdateTelephone(
-
int id,
-
string name,
-
string title,
-
string home_phone,
-
string mobile_phone,
-
string address,
-
string notes)
-
-
{
-
//Insert a new record in the Databse.
-
string Insert_Str = "insert into tel( " +
-
"name," +
-
"title," +
-
"home_phone," +
-
"mobile_phone," +
-
"address,notes)" +
-
" values ("+
-
" '"+name+"' ,"+
-
" '"+title+"' ,"+
-
" '"+home_phone+"' ,"+
-
" '"+mobile_phone+"' ,"+
-
" '"+address+"' ,"+
-
" '"+notes+"' )";
-
//////////////Update a new record in the Database.
-
string Update_str = "update tel set " +
-
"name='"+name+"'," +
-
"title='"+title+"'," +
-
"home_phone='"+home_phone+"',"+
-
"mobile_phone='"+mobile_phone+"'," +
-
"address='"+address+"'," +
-
"notes='"+notes+"'"+
-
"where id="+id+" ";
-
////////////Delete the record from the Database.
-
string Delete_str = "delete from tel where id= " + id + " ";
-
////////////////defining sqlcommands////////////////////
-
OleDbCommand Insert_Cmd = new OleDbCommand(Insert_Str, MyConnection.connect());
-
OleDbCommand Update_cmd = new OleDbCommand(Update_str, MyConnection.connect());
-
OleDbCommand Delete_cmd = new OleDbCommand(Delete_str, MyConnection.connect());
-
////////////////Defining the adapter command////////////
-
DA.InsertCommand = Insert_Cmd;
-
DA.UpdateCommand = Update_cmd;
-
DA.DeleteCommand = Delete_cmd;
-
////////////////update the datasource.///////////////////////
-
try
-
{
-
DA.Update(dttel);
-
}
-
catch (OleDbException ex)
-
{
-
MessageBox.Show("Warning" + ex.Message,
-
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
-
}
-
}
can any body help me.
2 1252
it seems something wrong with your query.Make sure your query is running fine...may be single quotes in one of the values may cause the problem
for example if you put address as leoiser's home in that single quotes will break the query,so replace everything with replace single quotes to two single quotes.. - address.Replace("'","''");
Thanks
Could you please tell which line is causing that exception!
Along with the string that was generated (can be picjked up from debug mode)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Alistair |
last post by:
hi peoples and masterful gurus (a little bit of grovelling never hurt
anyone...apart from the sore knees)
I'm after a little bit of advice on how to do something.
basically a history of the last 10 pages viewed or the id of the last 10
visitors to a page, but how do I make this "rolling"
e.g. a visitor looks at a page, his id is stored in an access 2000 db,
another vsitor then looks at the page, his id is also stored, when I get to
|
by: Prakash |
last post by:
Below is my code to delete a record in a continuous form. I can't
figure out any reason but sometimes (another) record gets deleted
instead of where the record pointer is positioned.
Small table - just 750 records ... no primary key defined.
Using Access 2003 under WinXP SP1.
There must be something I've overlooked. Maybe one of you gurus could
help.
|
by: Susan Bricker |
last post by:
I have a command button on a form that is supposed to Delete the record
being displayed. The record is displayed one to a form. The form is
not a Pop-Up nor is it Modal. Tracing the btnDelete event routine shows
that AllowDeletions is TRUE.
When the Delete button is clicked (without TRACE ON), I get a 'beep',
the recordselector (vertical bar on left of form) gets dark in color,
but the record is not deleted. Also, there is no error...
|
by: Bryan |
last post by:
hello all...
im trying to add a record to an sql db on ms sql server 2000, using vb.net.
seems to be working.. except for one thing, one of the columns in the
database is a bit datatype, and though i get no syntax errors when
compiling, i get an error indicated that the data would be truncated. the
field is login_status.
ive tried in quotes and not, giving it an integer variable with the number 1
|
by: A_PK |
last post by:
I am writing mobile application using Vb.net
when i click the last row of list view, and try to delete it....
will promtpy the following message "Additional information:
ArgumentOutOfRangeException"
what does that mean ?
I can delete any row without problem but except last row only....
| |
by: michel.ank |
last post by:
Hi,
I'm using the class PrintLines and my last record of page aren't with
the borders.
Somebody can help me?
Thanks,
|
by: prakashwadhwani |
last post by:
The Delete Event/Proc & "Save_Fields_In_Form_Header" Event/Proc in
my form were working perfectly.
However, after I added a call to the "Save_Fields_In_Form_Header"
Event/Proc in the "Current" Event of my form, and I now try to Delete
a record, I get ... Run-Time Error 3218 - Could not Update; Currently
Locked. My Access application then effectively freezes forcing me to
shut Access down & re-start.
The record DOES get deleted...
|
by: beacon |
last post by:
Hi everybody,
This is probably going to sound unorthodox, but I have to log records that are deleted...I know, go figure.
Anyway, I have a form with a (continuous) subform, and on the subform I have a command button, called cmdDelete, that launches a dialog form, called frmDeleteCurrentRecord, where the user has to enter their name and a reason.
I have managed, through a ton of trial and tribulation, found a way to delete the current...
|
by: BeemerBiker |
last post by:
I can't get rid of a "deleted" record in a database. Even if I delete it the record shows back up the next time I do an update.
The following code generates an error message when using "driver=microsoft access driver (*.mdb)" Either in the app QTADO or in my own perl script that uses dbi:ODBC
really simple command: "UPDATE mytable SET Field1='rec';
error message: "The Microsoft Jet database engine stopped the process because you and...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |