|
I apparently lost track of all my permutations. byte, short, and int all result in "invalid parameter" from save, but long appears to work. I almost forgot that the int and long are the same thing in mc++ but not c#.
Thanks anyway.
|
|
|
|
|
I have a datagrid, dataset, and sql server data source. I would like to be able to update my dataset through my datagrid. I thought binding the dataset to the datagrid would give me the ability to do this, but I guess I am wrong (I am new to C# and .NET). I have created a dataAdapter to update the datasource, but I would like to update the dataset first. Can any one help me get started here. What I have is a datagrid and would like to allow the user to do update, insert, and delete data then click a button that will sync the datagrid with the dataset. Any insight is appreciated.
|
|
|
|
|
Binding a Control to a DataTable or DataSet adjusts only Data in the DataSet NOT in the SQL-Server Table. That means that your input in your Datagrid will only change Data in the DataSet. You have to Update the Tables with the DataAdapter.Update(DataTable) / SqlDataAdapter.Update(...) Method.
So your Button to Update: SqlDataAdapter.Update(DataTable) /DataSet
DataTable dt=new DataTable("Table1");
..
..
SqlDataAdapter ada=new SqlDataAdapter(...);
ada.Update(dt);
Be aware of not to call DataSet.AcceptChanges/DataTable.AcceptChanges() before DataAdapter.Update()! because otherwise no data will be updated; after AcceptChanges all Rows are marked as unchanged and so the DataAdapter don't "find" Rows to Update! In the help files everywhere you can find
"AcceptChanges()" which is very irritating.
|
|
|
|
|
Thanks for the response, but I realize that binding a control to a dataset will only update the dataset. The problem is after i bind to the control and update the datagrid.....the data in the dataset is not being modified. is there any code i need to implement to get the dataset updaated with the the data the user has modified in the datagrid?
|
|
|
|
|
Now I think I understand your question:
You modify data in the datagrid by typing in some new text, numbers...but the datasets data isn'nt changed which has nothing to do with the Sql-Server side datatables.
If a Control is bound to a dataset, the datasets data is changed when the user changes data in the control at once. That means that your binding code may be wrong. Would you like to show me your binding code?
|
|
|
|
|
Here is the code for my data binding. The form has a datagrid and two drop down lists. One of the lists allows the user to choose the table to modify and click a button to retrieve the data in that table. Therefore, when the form initially loads, I only bind it to the dataset and not a particular datatable. After the user chooses a datatable from the drop down list, I have an event handler that updates the data binding. Thanks for any help.
The code below is the initial data binding where the control is bound to only a dataset:
this.dataGrid1.SetDataBinding(todv.dvm, null)
I call another object that creates and manipulates a dataviewmanager (todv). todv.Filterview returns a dataview. So in this case, I bind to a dataview.
The event handler to update the databinding:
private void retrieveBtn_Click(object sender, System.EventArgs e)
{
string selectedItem = comboBox1.SelectedItem.ToString();
DataView dvm2 = todv.FilterView(comboBox2.Text.ToString(),comboBox1.Text.ToString());
dataGrid1.SetDataBinding(dvm2, null);
}
|
|
|
|
|
I think that dataGrid1.SetDataBinding(dvm2, null); is wrong.
try:
dataGrid1.DataSource=dvm2;
What method is FilterView?
|
|
|
|
|
STW wrote:
try:
dataGrid1.DataSource=dvm2;
This is not possible as the DataSource property takes a string. Tried different ways to assign dvm2 to DataSource but did not work.
STW wrote:
dataGrid1.SetDataBinding(dvm2, null);
But this is working. I guess the question is, if I bind to a dataview and then make changes to data through the datagrid will the underlying datatable be modified as well. It seems like it should.
Here is the FilterView method. It just simply adds a filter on dataset:
public DataView FilterView(string dataTable, string filter)
{
DataView newView = dvm.CreateDataView(tom.tradarOmsMapping.Tables[dataTable]);
newView.RowFilter = "Oms like '"+filter+"'";
return newView;
}
|
|
|
|
|
No, the DataSource Property of a DataGrid needs an object which can be DataSet, DataTable, DataView.
So now I think now I understand your question.
Yes, all changes made in a datagrid will change the underlying DataTable, View. When you then Update via an DataAdapter, the new data will be written to the Sql-Table. The DataGrid is synchronised with the Table, View.
But now I'm not anymore sure if I understood your problems with the grid.
1. When you change your two lists is the correct Data shown in the DataGrid?
2. When you changed Data by writing in the DataGrid and update it, is the new Data written to the Sql-Server?
If you answer the two question with Yes I don't understand the problem.
|
|
|
|
|
No, DataGrid.DataSource needs an object which can be a DataSet, Table, View, ...You can read this in the help.
Yes, the DataGrid is "equal" to the Table. When you change Data in the Grid, the Table will change at once, too.
Two questions:
1. When you make changes to the two lists you have, is the correct Data shown in the Grid?
2. When you Update the Tables, DataSet is the new data written to Sql-Server?
|
|
|
|
|
Hi,
I have a client window (in a MDI app) with lot of controls - listboxes, buttons, pictureboxes, etc - on it. I want to show a scaled-down version of the window i.e. show a window 1/8th size of the original window with all the controls on it.
Is there a way to scale down the controls?
Something like:
Form newForm = new Form();
newForm.size = OriginalForm.size/8;
for(i = 0; i < controlsOnOriginalForm; i++)
{
// Get control from original form
// create same control, size it and put on the new form
}
Any suggestions / help would be appreciated.
Thanks,
Suhas
|
|
|
|
|
I don't think that there exists a "Scale" Methode for this problem.
But I see that your code above is the solution for your problem. You just have to iterate through the Controls, resize them and set the right position. Perhaps you'll find a good common method for this. Maybe the Anchor property of a Control helps you.
Perhaps this may help too:
Array a=new ArrayList();
this.form.Controls.CopyTo(a,0) //Copies the Controls to an array
Form f=new Form();
foreach(object o in a)
{
Control ctrl=(Control)o; //get the control
ctrl=this.RecalcControl(ctrl) //Common Method to fix size and location
f.Controls.Add(ctrl);
}
void RecalcControl(Control ctrl)
{
ctrl.Size=..
ctrl.Location=..
return ctrl;
}
Your problem will be a good education for C#
Good luck
Stefan W.
|
|
|
|
|
Ive been working with VC++ for a while and want to begin to learn C#.
Can anyone recommend a good book to learn C#?
Thanx for the help,
-Flack
|
|
|
|
|
I was new to programming when I decided to pick up C# -- Deitel & Deitel 'How to learn C#' was my first book but in reflection its not the best. I once borrowed a MS Press C# book which was way more usefull but I cant remember the title (posibly Inside C#). I guess I was looking for more about programming than just syntax... happy hunting and let us know what you find usefull.
gadgetfbi@hotmail.com
|
|
|
|
|
First of all, you need to learn C#, so go with
Inside C# 2nd Edition by Tom Archer (MSPress)
Immediately afterwards, read either one of these:
Applied .NET Framework Programming by Jeffrey Richter (MSPress)
Essential .NET by Don Box(Addison Wesley)
I have also lived some years in Spain, and there people don't accept that you speak bad spanish. I usually compensate by speaking loud and accusing people of being stupid because they don't understand me. It usually works quite well.
-jhaga on non-native languages
|
|
|
|
|
Hi,
I was in the same situation and this book was perfect for me as a C++ developer moving to C#:
C# and The .NET Platform, Second Edition
By Andrew Troelsen
Published: Jun 2003 - Apress
ISBN: 1-59059-055-4
1200 pp.
Price: $59.99
You can find it in Amazon, a link to the apress book:
C# and the .NET Platform
I bought later one from Apress about C# and Database programming... it's useful as well.
Good luck
Braulio
|
|
|
|
|
Ok, so I had to write a program in DBase and boy does DBase suck. I just can't even begin to tell you. Anyway, I'm umming and arring about re-writing the whole app in C# and learning C# at the same time.
My app currently uses a bunch of dbase .dbf files (tables) stored on a server and accessed via a network drive from about 8 client machines, all of which are over 1ghz and have 256mb ram or more.
It's task is to manage the accounts and rent payment for a large market with a lot of traders.
It needs to be able to do the following:
1) be quick (dbase is soo slow at updating controls, navigating and scrolling through grids)
2) need to be able to create and embed reports into the program (using a crystal reports viewer control?)
3) needs to be able to print to a dot matrix printer to pre-printed tractor feed paper of a custom size (with was problematic in dbase to say the least..)
4) needs an incremental search (text box bound to a datagrid and a combo box (to select search field) e.g. you select "Name" in the combo box, then type id "Fr" in the text box and the grid then shows the first row in the table who's name starts with "Fr" e.g. "Freddie".
5) needs to be able to handle record locking properly (i'm guessing an sql server or access database will be ok with this..)
6) needs a password control (yes, dbase was lacking one!)
7) need to be able to offer hotkeys on a per form (not per-control) basis. e.g. F2 = New, F3 = Edit, F4 = Save, ESCAPE = Abandon edit.
8) need validated/formatted input (e.g text boxes for phone numbers, currency and dates)
9) reports need to be easy to create (dbase's report designer sucks!)
Those are the main things that I require, I'm just sick of maintaining and developing this horrible DBase code and want to move to something else ASAP, but don't want to spend alot of time writing the application and pulling my hair out over stupid bugs.
I have written lots of C++ code (see www.HydraIRC.com ...) so I don't think picking up the language will be difficult, i'm more concerned with the abve tasks and whether you guys thing C# is suitable, or if not, what about Visual Basic .NET?
Also of concern is the amount of help I can get from other codes should the need arrise, are there lots of C# developers now? or are there more VB.Net developers?
Any urls, commends and advice would be appreciated before I jump in head first.
Thanks!
|
|
|
|
|
If you are c++ developer do it with C#,not VB.NET because it has C syntax. The things you want is really good to be written with C# and SQLServer.All these will take half or less code than C++ and it will really save time of developing. ALl the thingsd you want to do in this application is really DUCK SOAP inC#(.Net actually)In this site you can find many beginner articles about these steps in C# and you can ask your questions here too.Its really a big help.You will find C# something great.
But something that I'm not sure is a machine with 256mb ram and 1ghz is enough for run .net application or not.I think it is minimum requirement for it. Hope it helps.
Mazy
No sig. available now.
|
|
|
|
|
.NET (including C#) really shines for business/data-centric applications, so it should work well. You'll love the data capabilities of .NET.
Hydra wrote:
1) be quick (dbase is soo slow at updating controls, navigating and scrolling through grids)
.NET has good data binding capabilities, and it's fast for this.
Hydra wrote:
2) need to be able to create and embed reports into the program (using a crystal reports viewer control?)
You would need a third-party reporting component, such as (as you mentioned) Crystal Reports. There are a couple of really good ones for .NET.
Hydra wrote:
3) needs to be able to print to a dot matrix printer to pre-printed tractor feed paper of a custom size (with was problematic in dbase to say the least..)
Hmm... this one might be a problem. You might ask about this one on the C# forum. AFAIK .NET doesn't directly do text-only printing. But you can always use the Windows API printing functions if necessary, and it won't be any harder than using them from C++.
Hydra wrote:
4) needs an incremental search (text box bound to a datagrid and a combo box (to select search field) e.g. you select "Name" in the combo box, then type id "Fr" in the text box and the grid then shows the first row in the table who's name starts with "Fr" e.g. "Freddie".
That shouldn't be hard.
Hydra wrote:
5) needs to be able to handle record locking properly (i'm guessing an sql server or access database will be ok with this..)
Yes. BTW, if you're dealing with a large DB, don't use Access - use SQL Server.
Hydra wrote:
6) needs a password control (yes, dbase was lacking one!)
.NET has one, and there's also a better one here on CP.
Hydra wrote:
Those are the main things that I require, I'm just sick of maintaining and developing this horrible DBase code and want to move to something else ASAP, but don't want to spend alot of time writing the application and pulling my hair out over stupid bugs.
You're welcome to ask questions here on CP if you run into trouble.
Hydra wrote:
I have written lots of C++ code (see www.HydraIRC.com ...) so I don't think picking up the language will be difficult, i'm more concerned with the abve tasks and whether you guys thing C# is suitable, or if not, what about Visual Basic .NET?
C# is definitely suitable. As far as C# vs VB.NET, C# can do everything VB.NET can (except for optional parameters), plus some.
Hydra wrote:
Also of concern is the amount of help I can get from other codes should the need arrise, are there lots of C# developers now? or are there more VB.Net developers?
Judging by the amount of traffic in the forums, there are almost as many people doing C# as C++ (although not quite), and more people doing C# than VB. Anyway, there's bound to be plenty of people to answer your questions.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
This is off the topic of your question, but I went to your website (www.HydraIRC.com) and had a look at the screen shots. I really like your GUI and was wondering if maybe you had some sample code of how to accomplish the auto-hide, docking, screens etc. Maybe you could even do an article on it and post it here (at CP). It's a really nice interface.
Thanks.
|
|
|
|
|
hehe, it's already here on CP Check out the article in the WTL area by Sergey Kilmov (sp?)
And yeah, it's great!
|
|
|
|
|
Hi,
I am trying to have an Windows Applcation run over the network. The client machine has the required .NET framework, but when I launch the applciation it is giving me a TypeInitialization exception. It does not even hit the first line. Is there soemthing I need to take into consideration before an application can be run over the network? Thanks,

|
|
|
|
|
|
If you are interested in just executing the program from a network share, you will need to set permissions on each of the client computers.
Take a look at Administrative Tools > Microsoft .NET Framework Configuration and do soem MSDN searches for 'code access security'.
This will most probably be what is causing your exception.
Tatham Oddie (VB.NET/C#/ASP.NET/VB6/ASP/JavaScript)
tatham@e-oddie.com
+61 414 275 989
|
|
|
|
|
hi, what the difference betweem "Byte" and "byte"
|
|
|
|
|