Click here to Skip to main content
15,895,142 members
Home / Discussions / C#
   

C#

 
GeneralWeb Services Pin
Yondan406-Mar-03 6:10
Yondan406-Mar-03 6:10 
General2Questions: Application icon and username Pin
DionChen6-Mar-03 4:02
DionChen6-Mar-03 4:02 
GeneralRe: 2Questions: Application icon and username Pin
Danny Blanchard6-Mar-03 9:03
Danny Blanchard6-Mar-03 9:03 
GeneralRe: 2Questions: Application icon and username Pin
DionChen6-Mar-03 9:37
DionChen6-Mar-03 9:37 
GeneralRe: MemoryStream Pin
leppie6-Mar-03 6:54
leppie6-Mar-03 6:54 
GeneralLaunching of Web forms from Windows Form Pin
vivosh19786-Mar-03 2:48
vivosh19786-Mar-03 2:48 
QuestionHow do I flush keyboard buffer? Pin
Karman6-Mar-03 0:37
Karman6-Mar-03 0:37 
GeneralProblems with DataSet Pin
EnkelIk5-Mar-03 23:33
EnkelIk5-Mar-03 23:33 
I have a DataSet object defined by a XML-schema. One of the columns in the datatable should store an element also defined in the xml-schema (using ref="my_second_element").

I put the values I want to store in the dataset in an array of objects (Object[]) and set DataRow.ItemArray to my array. This works fine when I don't try to set the column of "my_second_element", but if I set that column I get an error. I have tried converting the object to store in that column to among other things an XmlElement but without luck. The error reads:

System.InvalidCastException: Specified cast is not valid.
at System.Convert.ToInt32(Object value)
at System.Data.Common.Int32Storage.Set(Int32 record, Object value)
at System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn't store <system.xml.xmlelement> in KuR_Id Column. Expected type is Int32

(KuR is the name of the datatable).

I get the impression that the object value is being stored in the record-place and not in the value-place. Can anyone tell me what I'm doing wrong? I have tried to set the datatype of the column to System.Object but I got the error that parent and child columns don't have type-matching columns.

Any help will be greatly appreciated Smile | :)
/EnkelIk

Code sample that may help to clarify my problem:

DataSet vscDS, vscDS2;
DataTable vscDT,vscDTP;
DataRow vscDR,vscDRP;
DataTableCollection vscDTC, vscDTC2;
DataColumn vscDC;
object[] arrDR=new object[9];
short sIndex;
XmlElement vscXElem;
XmlDocument vscXDoc= new XmlDocument();


vscDS=new DataSet("Register");
vscDS.ReadXmlSchema(strSchemaFile);
vscDTC=vscDS.Tables;
vscDT=vscDTC["KuR"];

vscDC=vscDT.Columns[8];

//Add values
if(vscDT!=null)
{
vscDR=vscDT.NewRow();

arrDR[0]="";
arrDR[1]="";
arrDR[2]="";
arrDR[3]=m_strKType;
arrDR[4]=m_strEBet;;
arrDR[5]=m_strPoint;
arrDR[6]=m_strBen;
arrDR[7]=m_strBet;

//Adding object
if(m_arrgodkP.Count>0)
{
vscDS2=new DataSet("Register2");
vscDS2.ReadXmlSchema(strSchemaFile);
vscDTC2=vscDS2.Tables;
vscDTProv=vscDTC2["PR"];
if(vscDTProv!=null)
{
//m_scPR is a self defined class and method ConvertRow returns its values in a DataRow
vscDRP=m_scPR.ConvertRow(vscDTP);

//Create xml dokument and load xmlstructure from dataset
vscXDoc.LoadXml(vscDS2.GetXml());
vscXElem=vscXDoc.DocumentElement;
//Add element
arrDR[18]=vscXElem;

}
}

vscDR.ItemArray=arrDR;


vscDT.Rows.Add(vscDR);
}
GeneralOLE objects in Crystal Report Pin
Anonymous5-Mar-03 22:44
Anonymous5-Mar-03 22:44 
General***drawing graphics on movie playing in mediaplayer*** Pin
henrykao5-Mar-03 19:31
henrykao5-Mar-03 19:31 
GeneralRe: ***drawing graphics on movie playing in mediaplayer*** Pin
S O S22-Mar-03 21:21
S O S22-Mar-03 21:21 
GeneralAccessing the Parallel Port Pin
linhpdinh5-Mar-03 14:33
linhpdinh5-Mar-03 14:33 
GeneralRe: Accessing the Parallel Port Pin
Furty6-Mar-03 21:52
Furty6-Mar-03 21:52 
Questionhow to resize a datagrid control when the form resizes? Pin
stephen.hazel5-Mar-03 14:03
stephen.hazel5-Mar-03 14:03 
AnswerRe: how to resize a datagrid control when the form resizes? Pin
Kannan Kalyanaraman5-Mar-03 16:03
Kannan Kalyanaraman5-Mar-03 16:03 
GeneralRe: how to resize a datagrid control when the form resizes? Pin
stephen.hazel6-Mar-03 6:03
stephen.hazel6-Mar-03 6:03 
AnswerRe: how to resize a datagrid control when the form resizes? Pin
A.Wegierski5-Mar-03 20:33
A.Wegierski5-Mar-03 20:33 
GeneralRe: how to resize a datagrid control when the form resizes? Pin
stephen.hazel6-Mar-03 6:05
stephen.hazel6-Mar-03 6:05 
QuestionDelete key not triggering KeyPress in TextBox?? Pin
markmalin5-Mar-03 6:29
markmalin5-Mar-03 6:29 
AnswerRe: Delete key not triggering KeyPress in TextBox?? Pin
Stephane Rodriguez.5-Mar-03 11:00
Stephane Rodriguez.5-Mar-03 11:00 
GeneralRe: Delete key not triggering KeyPress in TextBox?? Pin
Arun Bhalla6-Mar-03 10:49
Arun Bhalla6-Mar-03 10:49 
GeneralModular Programs Pin
Jon Newman5-Mar-03 5:46
Jon Newman5-Mar-03 5:46 
GeneralRe: Modular Programs Pin
Stephane Rodriguez.5-Mar-03 6:48
Stephane Rodriguez.5-Mar-03 6:48 
GeneralRe: Modular Programs Pin
Jon Newman5-Mar-03 7:17
Jon Newman5-Mar-03 7:17 
GeneralRe: Modular Programs Pin
Stephane Rodriguez.5-Mar-03 9:06
Stephane Rodriguez.5-Mar-03 9:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.