Hi
I am new to programming. learning c# , asp.net.
write a simple program: to get the id from database and save it to arraylist to find the max(id).
and getting exception: Specified cast is invalid.
at line: int low = (int)arrm[i];
Appreciate any help.
Thanks
Sep 12 '07
27 2927
Hi Plater ,
Thank so very much for all your help.
my first column is id and it is numeric datatype in sql database.
with your help I was able to solve my problem.
But Now, I got one more little issue. which is I am trying to do a query with like clause and i think I am not getting write syntax.
Need help with that please.
Select paperid from Allreport where paperid like ' "+DateTime.Now. ToString("yymm" )+%" ' ;
my paperid will be for this month. 070901,070902 depending on as many time report was modified by user and I like to get the all paperid for a perticular month.
thank you,
Try writing it as - +DateTime.Now.ToString("yymm") " + "%"
Hi R,
No , that did not work either.
Thanks,
Plater 7,872
Recognized Expert Expert
Hi R,
No , that did not work either.
Thanks,
What is it telling you now then?
"it doesn't work" is not a very helpful reply
This didn't work? -
string sql="Select paperid from Allreport where paperid like ' "+DateTime.Now.ToString("yymm")+"%' ";
-
I have value in id field but the query doesn't return any value.
No error but doesn't give any result.
Thanks,
Plater 7,872
Recognized Expert Expert
Have you tried your query's in the sql query window for your sql server (ie not in code) too make sure they return something? -
Select paperid from Allreport where paperid like '0709%'
-
if that statement in your sql query window returns no results then you don't have matching data.
Ok, I saw the problem.
paperid is Numeric datafield in sql table. So, when value hits the database it removes the "0 " from front.
Ex , 070901 hits database it goes for 70901..
that's why query wasn't giving any result.
Any idea on how to have paperid store in database like 070901 and not 70901?
Thanks,
Ok, I saw the problem.
paperid is Numeric datafield in sql table. So, when value hits the database it removes the "0 " from front.
Ex , 070901 hits database it goes for 70901..
that's why query wasn't giving any result.
Any idea on how to have paperid store in database like 070901 and not 70901?
Thanks,
The table design was wrong then.
Change the table column type to varchar2 whatever type that your database uses for strings.
Thanks but then I need to increment id by1 each time the page will modify. If I will change the id to varchar then I need to store that query result some like in array or something where then convert to "Int".
How can I accomplish this? How can I store my query into array?
Thanks,
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: .Net Sports |
last post by:
I'm getting a "Specified cast is not valid" error that does not point
to the line with the code in error, but instead :An unhandled exception
was generated during the execution of the current web request.
Information regarding the origin and location of the exception can be
identified using the exception stack trace below.
The stack trace is just a lot of system class stuff with no real
explanation of where the error is. Wondering the...
|
by: Arjen |
last post by:
Hello,
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Specified cast is not valid.
Line 176.
Source Error:
|
by: Nick Flandry |
last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my
development environment (Win2K server running IIS 5) and a test environment (also Win2K server
running IIS 5), but fails on IIS 6 running on a Win2003 server.
The web uses Pages derived from a custom class I wrote (which itself derives from Page) to provide
some common functionality. The Page_Load handler the failing webpage starts out like this:
...
|
by: PK9 |
last post by:
I am looking for assistance in pinpointing the cause of the following
exception. I am getting a "Specified Cast is not valid" exception on my
page. I am trying to populate a datagrid. One of my columns is a template
column where I'd like to evaluate the data brought back from the db and
populate the column with a "Y" or "N" depending on the value in the db. Here
is the code that is causing it as well as the error (below).
ERROR...
|
by: Biva |
last post by:
Hello All,
Please help. I get the following error from my webpage:
System.InvalidCastException: Specified cast is not valid.
at Time.MaintAtRiskProjects.UpdateProject(String Project, String
AtRiskCode, String Comment)
Code for UpdateProject(String Project, String AtRiskCode, String Comment)
is:
| |
by: James |
last post by:
I'm a newbie to vb.net, and classes were something I never played with in
"standard" vb, but...
Basically,part of my program comprises of some tcp/ip stuff, and I used the
following code to start off the connection:
Public Sub Main()
Const PortNumber As Integer = 8022
Dim tcpListener As New TcpListener(PortNumber)
tcpListener.Start()
|
by: df |
last post by:
I'm seeing a strange problem in the Web App config tool: After
creating a role and a user, going back to the Security tab home page, I
get a "Specified cast is not valid" error.
I've set up my web application to use SQL Server to store the
Membership database using aspnet_regsql.exe and have successfully
opened the Web Config Tool.
Then, I create a role, and go look in the SQL Server aspnet_roles
table, and there is the role. All...
|
by: Kashiefah |
last post by:
Hi, I keep on receiving this error when I click on the edit email link from the datagrid:Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Specified cast is not valid.
Source Error:
Line 44: while...
|
by: one320b |
last post by:
I've read through numerous postings by other users here but was not able to find the solution to my issue. It's probably a simple one, but it's racking me at this point.
I have two databases in MS Access with a table "Affiliation". Both contain four columns/fields. I am writing an application to pull some data from Table1's affiliation table and inserting it into Table2's affiliation table. The datatypes are all the same for all four fields...
|
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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: 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...
|
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
| |