Re: help required in c# code

  • From: prateek aggarwal <prateekagarwal99@xxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Tue, 10 Aug 2010 14:46:14 +0530

dear sameer,

while making the table in design view for instance, press f6 key
keeping your cursor in the intended field to focus on the field size
property.

  here, enter the new field size in the Field Size property. You can
choose from the following values:
 Byte : For integers that range from 0 to 255. Storage requirement is
a single byte.
 Integer : For integers that range from -32,768 to +32,767. Storage
requirement is two bytes.
 Long Integer : For integers that range from -2,147,483,648 to
+2,147,483,647. Storage requirement is four bytes.

 Single : For numeric floating point values that range from -3.4 x
1038 to +3.4 x 1038 and up to seven significant digits. Storage
requirement is four
bytes.
 Double : For numeric floating point values that range from -1.797 x
10308 to +1.797 x 10308 and up to 15 significant digits. Storage
requirement is eight
bytes.
 Replication ID : For storing a GUID that is required for replication.
Storage requirement is 16 bytes.
 Decimal : For numeric values that range from -9.999... x 1027 to
+9.999... x 1027. Storage requirement is 12 bytes.


many thanks.

prateek agarwal.


On 8/10/10, sameer manohtra <sameermanohtra@xxxxxxxxx> wrote:
> hi mate,
> actually, I have started working with ado.net very recently and I’m
> not a much experienced programmer too.
> Thanks for telling me the way, it worked.
>
> The project I’m doing, I’ve got one more problem:
>
> I have to use Microsoft access as database for this project. Since I
> have been working with sql from whatever days I’ve learned ado.net, I
> have hardly used access before this project.
> Now when I’m trying to work with it, some of the things looking
> puzzling to me and I’m not able to figure out a way to resolve them.
>
> one recent is that I’m not able to store a double  value which is not
> a currency.
>
> My user will be entering a value like 4.00  which I need to store in
> the database.
> I’m getting error while  trying to store it with currency set as dataType.
> In access, I did not find a dataType that represents decimal/double number.
>
> Any idea how can I do it?
>
> I’m learning a lot from this new project, but still I’m stuck up in a
> lot of things before being able to complete the software that I am
> developing.
>
> Can you please help me doing this?
>
> Sameer.
>
>
>
> On 8/9/10, black ares <matematicianu2003@xxxxxxxxxxx> wrote:
>> Hello, you miss understood the use of the datareader.
>> The data reader is a class which help you to read results from a query row
>> by row.
>> So it is what we call connected way to use with databases.
>> After the line with executereader,
>> you must do
>> dr.read();
>> then dr.get(x) or dr.get ("columnName");
>> for your help, when you want to get only a number,
>> so when you know that the query you use will return only a value, so a
>> table
>> formed from a row and a column,
>> you can use better executeScalar instead of others.
>> Execute scalar retyurns an object you can cast using regular casting
>> algoritm so you can do:
>> int val=(int)cmd.executescalar(...);
>>
>> ----- Original Message -----
>> From: "sameer manohtra" <sameermanohtra@xxxxxxxxx>
>> To: "programmingblind" <programmingblind@xxxxxxxxxxxxx>
>> Sent: Monday, August 09, 2010 1:47 PM
>> Subject: help required in c# code
>>
>>
>> Hi mates,
>> I am doing a project in c# with ado.net and I got  stuck at a place.
>>
>> At one place in the code, i’m reading a column of table of my database
>> and want to store it  in a local variable.
>>
>> Basically, the table has a number, which I will use further for some
>> addition/subtraction operation.
>>
>> The problem is, that I’m not able to convert the output of the
>> dataReader into integer.
>> It gives the following exception:
>>
>> ---
>> System.InvalidCastException was unhandled
>>   Message="Unable to cast object of type
>> 'System.Data.OleDb.OleDbDataReader' to type 'System.IConvertible'."
>> ---
>>
>> my code is this:
>> ---
>> con.Open();
>>                     OleDbCommand cmd = new OleDbCommand("select
>> lastBalance from Textile");
>>                     cmd.Connection = con;
>>                           OleDbDataReader dr= cmd.ExecuteReader();
>>
>>
>>                                                     dr.Close();
>>                                                     con.Close();
>>
>>                                                      int balance =
>> Convert.ToInt32(dr);
>>    ---
>>
>> I have tried all that I knew, but could not find  a solution.
>>
>> Can you help?
>>
>> Please, tell me how can I convert  the output of dataReader to an integer
>> value.
>>
>> The help will be appreciated.
>>
>> sameer
>> __________
>> View the list's information and change your settings at
>> //www.freelists.org/list/programmingblind
>>
>> __________
>> View the list's information and change your settings at
>> //www.freelists.org/list/programmingblind
>>
>>
> __________
> View the list's information and change your settings at
> //www.freelists.org/list/programmingblind
>
>
__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

Other related posts: