|
Yes, this was exactly what I was looking for. Thank you! -mutty
|
|
|
|
|
Hi
In c-sharp windows form,
create two xml files with some sample data in it.also to have a forign key in the table.
Then read them into the dataset.so your dataset should have two tables.Then create a relation betwenn those two tables in the dataset.
then place a datagrid and display it.
pls anyone teach me or just with an small example help me to do this type.
santhosh
|
|
|
|
|
You should use the class DataRelation. Search for DataRelation in MSDN, there are many samples.
Live Life King Size
Alomgir Miah
|
|
|
|
|
I am new to c#, so i am learning right now.
In a form , i had designed with a datagrid and a button.
now i have added a datset
and
coded as fllows
private void button1_Click(object sender, System.EventArgs e)
{
DataSet ds = new DataSet();
DataSet xml1 = new DataSet();
xml1.ReadXml("C:\\CDEV\\relationcosttypeandcode\\cost_code.xml");
DataTable dt1 = xml1.Tables["cost_code"].Copy();
DataSet xml2 = new DataSet();
xml2.ReadXml("C:\\CDEV\\relationcosttypeandcode\\cost_type.xml");
DataTable dt2 = xml2.Tables["cost_type"].Copy();
ds.Tables.Add(dt1);
ds.Tables.Add(dt2);
DataColumn parentCol = ds.Tables["cost_code"].Columns["cost_type"];
DataColumn childCol = ds.Tables["cost_type"].Columns["cost_type"];
DataRelation relTable1Table2;
relTable1Table2 = new DataRelation("cost_typecost_code", parentCol, childCol);
ds.Relations.Add(relTable1Table2);
dataGrid1.DataSource = ds;
}
after running this i get a error when clicking the button
"Column argument cannot be Null".
Pls any one help me to do this
santhosh
Nation of complete domination
|
|
|
|
|
Hi
I am trying to connect SQL server database 2K, which is in different machine from web server but in the same domain, from ASP.NET page but it gives error message "SQL Server does not exist or access denied" but with same connection string & same server I can connect using windows form or other application.
Does anyone has got any clue on that
Would much appreciate your help.
Thank You
Share knowledge to enhance your learning
|
|
|
|
|
What kind of authentication does your SQL server use? If you are using Windows authentication, then you probably don't have privlieges for the ASP.NET user.
Michael
CP Blog [^] Development Blog [^]
|
|
|
|
|
hi friends how can i get a collection of the names if textboxes on a panel control
please i need practical examples
|
|
|
|
|
ArrayList names = new ArrayList();
foreach(Control ctrl in myPanel.Controls)
{
if(ctrl is Textbox)
{
names.Add(ctrl.Name);
}
}
Roger Stewart
"I Owe, I Owe, it's off to work I go..."
|
|
|
|
|
thanks for your reply
i think i need to know a lot about u
my approach was about 4 lines of code
but your reply has help me understand.
i'm from ghana and working as a programmer
with the softtribe
|
|
|
|
|
hi
im new to c# and this is my first attempt to create a database.. right now i only have a concept, i donno how to get started or what i need to do exactly to carry out my plan..
i've separated my groups of data in tab pages.. so now, each tab page consist of a different type of data..
1) when the user saves the tab page of data, i want the data to go into the database.. but how do i "throw" the data into my database?
2) i need to create a few sets/types of sample data eg. types of food taken and personal particulars.. where do i go to to create my sample data n how do i store these sample data in my database?
3) more importantly, im not even sure what database to create.. microsoft access or microsoft sql server or others.. which database is the best/easiest to use for my app?
4) my app is something like this >>
let's say i've these buttons : updateBtn1, viewBtn1, updateBtn2 n viewBtn2.. the user chooses what he wants to click and the page will be displayed.. if this button is to view only and it is to open a tab page about types of food taken, im supposed to retrieved only types of food taken from database and display in the tab page.. i need it to sort and only retrieve food taken and leave out personal particulars which is also kept in the same database..
if the button clicked is to open tab page to update food taken, i need to get the relevant data frm database and let user edit those data before he saves them again to database..
so my question is how do i open/display/retrieve only the relevant data for THAT tab page AND how do i save it back to database? note: the same data shd NOT be written again to database, only add NEW data in to database.. how to do this? when the user loads (whether to view or update) tab page by clicking the button, i want the page to display both old data + new data in a datagrid for example (old data means data that's already in database that is my sample data & new data means the data that was updated/added in to database..
i really appreciate it if u cld provide me with some examples of codes and how they work or some help articles or anything that u think will help..
thank you so much for trying to help! =)
|
|
|
|
|
hi i think u should read more about the database connection
and about dataset
with this you will have more idears about .net database
|
|
|
|
|
|
Iam searching for a way to display incoming strings(over the network) and the resulting outgoing string, in an automatically scrolling window,
at the moment i use two textfields but they always run full.
windows should look like this:
______________________
| | |
| | |
-----------------------
in the middle there should be a scrollbar or therelike to scroll to the previous strings.
in the left field the incoming string is printed, and in the right field the response string.
the both strings shall be in the same line always too, so one can see what incoming string belongs to wich outgoing string.
so any ideas on what to use for that in a windows form in visual c#?
thnx in advance, mike
|
|
|
|
|
Hi!
I can't seem to make it work. I select a row in a datagrid and press a delete button. That row is then deleted. But if i add/delete many rows, then close and reopen my dialog and try to delete a row again, the row with index 0 is deleted instead of the one i have selected. I have tried to use currency manager to delete and everything, but I can't make it work properly.
This is how I delete a row:
<br />
if(_currencyManager.Current.GetType() != typeof(DataRowView)) return;<br />
<br />
DataRowView dr = (DataRowView)_currencyManager.Current; <br />
dr.Delete(); <br />
_currencyManager.EndCurrentEdit();<br />
_currencyManager.Refresh(); <br />
_dtPplan.AcceptChanges();<br />
I set the currency manager like this:
<br />
_currencyManager = (CurrencyManager)this.BindingContext[dgPplan.DataSource, dgPplan.DataMember];
And fill the table with data like this each time i open the dialog. Just so i'm sure it got the latest data:
<br />
_dtPplan.Rows.Clear();<br />
foreach(PPlan pPlan in valueObject.PPlan) <br />
{ <br />
DataRow dr = _dtPplan.NewRow();<br />
dr[NetworkKeywords._cCriteria] = pPlan.Criteria;<br />
dr[NetworkKeywords._cParameter] = pPlan.Parameter;<br />
dr[NetworkKeywords._cValue] = pPlan.Value;<br />
dr[NetworkKeywords._cUnit] = pPlan.Unit;<br />
_dtPplan.Rows.Add(dr);<br />
}<br />
_dtPplan.AcceptChanges();<br />
<br />
_currencyManager = (CurrencyManager)this.BindingContext[dgPplan.DataSource, dgPplan.DataMember]; <br />
I really need help on this. This datagrid/datatable is driving me crazy.
Thanks in andvance
Atle
|
|
|
|
|
I would suggest you that,instead of having a delete button, u keep a contextmenu for the datagrid, and in the delete menu click event,u delete the selected row..sumthin like this..
int rowIndex = dataGrid1.CurrentRowIndex;
dataTable.Rows[dataGrid1.CurrentRowIndex ].Delete();
//then call the function to delete the row
and u retrieve the data correctly
try it..datagrids n datatables ain't so bad
|
|
|
|
|
I also have an "Add" and "Delete All" button that I need. The way you are mentioning her will work with a button too won't it? Just use your code inside the buttons aciton?
What happens when I sort the datagrid? Then the row indexes in the datagrid won't correspond to the row indexes in the datatable will they? Only the datagrid's rows are sorted, or? Then I will need the currency manager to keep track of that?
- Atle
|
|
|
|
|
I agree with deep7.
You can have a context menu with the following items
Delete,
Delete All
You can add a new row on mouse click on the white region.
private void OnGridMouseUp(object sender, MouseEventArgs e)
{
//Get Current Point
this.hitTestGridInfo = this.dataGridAllocation.HitTest(new Point(e.X, e.Y));
//Capture Grid Body Event
if (this.hitTestGridInfo.Type == DataGridEx.HitTestType.None &&
e.Button == MouseButtons.Left )
{
newDataRow = this.dataTable.NewRow();
this.dataTable.Rows.Add(newDataRow);
}
}
As far as sort order is concerned, you can use,
private DataRow GetDataRowAt(int index)
{
DataRow dataRow = null;
CurrencyManager currencyManager = null;
currencyManager = (CurrencyManager)this.BindingContext[this.dataTable];
if ( currencyManager != null )
{
dataRow = ((DataRowView)currencyManager.List[index]).Row;
}
return dataRow;
}
Live Life King Size
Alomgir Miah
|
|
|
|
|
Looks like the datagrid is messed up after refilling the datatable or something. You see how i fill it with data in my first post. Is there another way to do it? I need to fill in some data from an arraylist. I refill the datagrid according to what I select in a combobox.
It seems my problem is that after clearing and refilling the datatable with data a couple of times (selecting differend things in the combobox), the datagrid returns selected row index = 0 for each and every row i press. Then suddenly it can return index out of bounds exception when I press a row??
- Atle
|
|
|
|
|
Hmm....seems like it likes
<br />
foreach(DataRow row in _dtPplan.Rows) <br />
{<br />
row.Delete();<br />
}<br />
_dtPplan.AcceptChanges();<br />
for deleting all rows than
<br />
_dtPplan.Rows.Clear()<br />
I have to test it a little more, but it seems like the index problem is gone now. It works with the add and delete buttons in the form by the way. Thanks for your help.
- Atle
|
|
|
|
|
hi all,
I need to shedule a Task in windows 2000.I can easily do it using Control Panel--->Sheduled Task ..
But How am I shedule a task using a C# Application..?
Can any one please help me.?
thanks in advance..
|
|
|
|
|
|
I'm using
System.IO.Directory.GetCreationTime(folderName)
to get the creation date of a folder, but it throws an ArgumentOutOfRangeException with the message
"Specified argument was out of the range of valid values.
Parameter name: Not a valid Win32 FileTime."
The folder in question is on a CDR that was burnt on a PC with a different datetime locale. Why is it that Windows Explorer can display the datetime of the folder without any problems, but the .net framework chokes on it? Does System.IO.Directory require some sort of CultureInfo to parse dates? If so, where do I specify this?
Thanks in advance
|
|
|
|
|
I am trying to limit the amount of time an ASP.NET Web Service can spend processing a client’s request.
Currently if the client sets it’s timeout to Infinite the server will allow the request to complete; however I want to stop the request and send a custom response back to the client after a specified time limit.
What is the best way of achieving this?
|
|
|
|
|
How can i get the hard disk Id or the motherboard ID programatically?
hosny
|
|
|
|
|