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

Problem updating Access Database


Hi,

I'm new to C sharp and currently writing a small program that uses an Access 2003
database.

I am currently having a problem when updating a row that includes numeric data.

When updating just the text fields in the row everything works fine with the
following command:
dbCommand.CommandText = "UPDATE ScanLibTable SET Regex = '" +
txtRegex.Text.ToString () + "', Description = '" +
txtDescription.Text.ToString () + "' WHERE Key = " +
intCurrentKey.ToString () + ";" ;
but when attempting to also update a numeric field with the index value from a
drop down list I get an except because the UPDATE command is invalid:

int intLang = lstLanguage.SelectedIndex;

dbCommand.CommandText = "UPDATE ScanLibTable SET Regex = '" +
txtRegex.Text.ToString () + "', Description = '" +
txtDescription.Text.ToString () + "', Language = " +
intLang.ToString() + " WHERE Key = " + intCurrentKey.ToString () + ";" ;
Can someone point out what I'm doing wrong?

Cheers
--
----------------------------------------------
Posted with NewsLeecher v3.0 Final
* Binary Usenet Leeching Made Easy
* http://www.newsleecher.com/?usenet
----------------------------------------------
Nov 17 '05 #1
1 1647

"delta7" <de****@nospam.co.uk> wrote in message
news:gL********************@giganews.com...

Hi,

I'm new to C sharp and currently writing a small program that uses an
Access 2003
database.

I am currently having a problem when updating a row that includes numeric
data.

When updating just the text fields in the row everything works fine with
the
following command:
dbCommand.CommandText = "UPDATE ScanLibTable SET Regex = '" +
txtRegex.Text.ToString () + "', Description = '" +
txtDescription.Text.ToString () + "' WHERE Key = " +
intCurrentKey.ToString () + ";" ;
but when attempting to also update a numeric field with the index value
from a
drop down list I get an except because the UPDATE command is invalid:

int intLang = lstLanguage.SelectedIndex;

dbCommand.CommandText = "UPDATE ScanLibTable SET Regex = '" +
txtRegex.Text.ToString () + "', Description = '" +
txtDescription.Text.ToString () + "', Language = " +
intLang.ToString() + " WHERE Key = " + intCurrentKey.ToString () + ";" ;
Can someone point out what I'm doing wrong?


Well, waht exception were you recieving? Is the data different between the
two? Have you tried the second sequence using literal values instead of
using all teh variables?

I can't say whats wrong without more information.

Also, FYI, you don't need all of those ToString() calls there. The text
members are already strings and the compiler will call ToString()
automatically on the integers
Nov 17 '05 #2

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

Similar topics

4
by: Frnak McKenney | last post by:
I'm using an in-core DataSet as an image of my application's 'database' (a multi-table Access97 mdb file). Updates are made to the DataTables within the DataSet via forms with bound TextBoxes,...
5
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated...
14
by: Nick Gilbert | last post by:
Hi, I have an asp.net application which runs from a CD-ROM using Cassini. As such, it is single user only. The application connects to an Access database when it is loaded, and keeps the same...
14
by: Lars Netzel | last post by:
A little background: I use three Datagrids that are in a child parent relation. I Use Negative Autoincrement on the the DataTables and that's workning nice. My problem is when I Update these...
2
by: Alexey.Murin | last post by:
The application we are developing uses MS Access 2003 database (with help of ADO). We have noticed that during massive records updating the size of the mdb file increases dramatically (from 3-4 to...
5
by: Brad Baker | last post by:
I'm trying to write a simple asp.net page which updates some data in a SQL database. At the top of the page I have the following code: <%@ Page Language="C#" Debug="true" %> <%@ import...
0
by: JACompute | last post by:
I have an invoicing system that uses a VB6 program to post new invoice entries to a centralized Vendor management system (also in VB6), via a Web server and some ASP code. The system has been in...
13
yolenman
by: yolenman | last post by:
Hello - This is my first posting to this group, so please bear with me. Also note, that while I'm intelligent, databases are not in my field of knowledge. I'm working with a small limousine...
11
by: SAL | last post by:
Hello, I have a Gridview control (.net 2.0) that I'm having trouble getting the Update button to fire any kind of event or preforming the update. The datatable is based on a join so I don't know...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...

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.