473,503 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Public member 'Value' on type 'String' not found. Error

77 New Member
Hi all,
Here is the code that I have:


Expand|Select|Wrap|Line Numbers
  1.  For h = 2 To dt.Rows.Count - 1
  2.                 For j = 0 To 11
  3.  
  4.                     Excel.Cells(h, k).value = (dt.Rows(h).Item(j).Value).ToString
  5.                     k += 1
  6.                 Next
  7.             Next
  8.  

I get this error:
Public member 'Value' on type 'String' not found.

What should I do?
Aug 22 '08 #1
8 12696
Curtis Rutland
3,256 Recognized Expert Specialist
Well, it seems like dt.Rows(h).Item(j) is a string. Strings don't have a property called value. So you don't need that or the .ToString part, which you are doing incorrectly anyway. ToString is a method, and must be called as such:
.ToString()

Hope that helps.

Also, I noticed that you don't show where you initialize "k". Your loop variables are h and j, where does k come from?
Aug 22 '08 #2
Sep410
77 New Member
Thanks,
Now I have another problem. One of my columns contains system’s Id which starts it 08- .for example:08-1 or 08-25.

This columns in excel will be shown as date and it will be 1-Aug or 25-Aug.

What can I do?
Aug 22 '08 #3
Sep410
77 New Member
In the same code I have to get the value for datatable from datagrid:
dt = dg.DataSource
And I need to edit dt to export it to excel but I don’t want my datagrid’s content to have the same changes.right now all the changes that I apply to dt is effected datagrid too.

How can I stop that?
Aug 22 '08 #4
Curtis Rutland
3,256 Recognized Expert Specialist
As to the first question, I can't help much because I don't have any experience programming for Excel. But I'm sure there is a way to set a column data type.

As to the second, you need to learn a bit about Object Oriented Programming. When you reference an object, you aren't creating a copy of that object, you are passing a pointer to that object. Very efficient and useful, but it can have unintended consequences if you don't know about it.

You need to use the .Clone() method of the DataTable, and then copy the rows across.
Aug 22 '08 #5
Sep410
77 New Member
As to the first question, I can't help much because I don't have any experience programming for Excel. But I'm sure there is a way to set a column data type.

As to the second, you need to learn a bit about Object Oriented Programming. When you reference an object, you aren't creating a copy of that object, you are passing a pointer to that object. Very efficient and useful, but it can have unintended consequences if you don't know about it.

You need to use the .Clone() method of the DataTable, and then copy the rows across.
Thanks for the help.
I should learn about it.
Aug 22 '08 #6
Sep410
77 New Member
I tried .Clone() but I still have sace problem!
Aug 22 '08 #7
Curtis Rutland
3,256 Recognized Expert Specialist
Are you sure you are using it right? Post that part of your code.
Aug 22 '08 #8
Plater
7,872 Recognized Expert Expert
Are you doing:
dt = dg.DataSource.Clone()
???
Aug 22 '08 #9

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

Similar topics

2
3056
by: Jurgen Oerlemans | last post by:
Hello, I want to change to forecolor of a label. The label is named "lblDevice1" I create a variable called Var Dim Var Var = "lblDevice1" So the next step is: Var.ForeColor =...
18
2076
by: Janaka | last post by:
I'm having a discussion with my colleagues here on good programming standards. One thing we haven't agreed on is the use of properties in classes vs using member variables. Now everyone knows...
6
5404
by: tshad | last post by:
The error I am getting is: ******************************************************************* Exception Details: System.InvalidCastException: Cast from type 'DBNull' to type 'String' is not...
1
2511
by: Randall Parker | last post by:
Using VS 2003 and Cassini web server. I'm new to ASP.Net and so this may be a dumb question. I'm getting an error where the type 'FarmLand.WebForm1' is not found. The Codebehind C# source file...
8
10465
by: Jan Kucera | last post by:
Hi, I have structure like this: namespace Namespace { public class User { public Subnamespace.Settings Settings = new Subnamespace.Settings(); } namespace Subnamespace {
9
1639
by: Mirko Puhic | last post by:
Is there a way to properly do this? struct Derived; struct Base{ Derived der; };
4
1722
by: jrx | last post by:
I've got my_error exception type, defined as: class my_error : public std::runtime_error { public: my_error(const std::string& msg) : std::runtime_error(msg) {} }; Then, I've got Wrapper...
1
1632
by: =?Utf-8?B?RXJpY2E=?= | last post by:
Hello all. I really hope someone can help me solve this error: I am getting the following error: Public member 'PlanID' on type 'DataRowView' not found. Here is the relevant code: ...
0
1170
by: Jon | last post by:
Hello all, I recently posted a question about a tool that would create the public member variables for a selected set of private member variables - when there's 10 - 15 privates, it can be very...
0
7202
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,...
0
7084
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...
0
7278
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,...
1
5013
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...
0
4672
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...
0
3167
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...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
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 ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.