|
make findandsearch window topmost
|
|
|
|
|
Hi Kalyan,
Thanks for your Reply.
I have got it
I have made the form declaration globally.
With Thanks
Nas
|
|
|
|
|
Hi all, I started playing around with ADO.NET, so what I did was create a database with a table called products, then I created the form, set the dataset to grid binding and then drag that table from the data source tab onto the form. It then created the gridview, added the binding navigation bar and everything, so I can view all the data, add new fields and save them.
So if I add new values in the grid and save them via the binding navigation bar it is saved to the data set and I can view every thing further in the program, but once I close the entire program and then open it again the values were never saved to the database? What am I missing or not doing?
Thanks in advance.
He who laughs last is a bit on the slow side
|
|
|
|
|
hi
dude what happens when u use a dataset it is on the on memory..
it has to effect the database dataset wont effect the database until u do it
u need to take the help of dataadapter and update the database
byebye
|
|
|
|
|
I am using a data adapter, but it looks as if it only updates the dataset and not the database. So I can create entries, update entries and it all is fine, if you go else where in the program and check the values they are 100%. But they aren't in the database it self, the changes never took effect on the database. So the next time I start the program, none of the changes where saved
He who laughs last is a bit on the slow side
|
|
|
|
|
kaylan is correct... you need to call the dataAdapters.Update() function. Only then will the changes be made to the database.
|
|
|
|
|
I do.
Here's the code to the update
private void productsBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
try
{
this.Validate();
this.productsBindingSource.EndEdit();
this.productsTableAdapter.Update(this.productsDataSet.Products);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error");
}
He who laughs last is a bit on the slow side
|
|
|
|
|
It's over a year ago that i worked with ADO.NET and C# but i try to help you
You have seriously a DataAdapter to this DB-Table.
With DataAdapter.Update() you save all the changings to the Database.
( if all Commands are correct --> To fill in (DataAdapter.Fill() to fill a Dataset) the data is easy,
the DataAdapter needs only the SELECT-Command, but to update the Table it needs
all 3 other Commands ( INSERT,UPDATE and DELETE )
Perhaps it's a problem of the Commands.
But using the Binding Navigator seems me that it works directly on the DB and not on a Dataset
( i never used this technology (only Dataset) )
But the Commands are very important.
I hope i could help you a little bit
|
|
|
|
|
Thanks for the quick reply, I checked the the commands and they are all there (Insert, Update and Delete)and working (checked them just to be sure). I use the update command of the DataAdpater to save the values, and all seems well through out the rest of the program, but the actual changes where never made to the database, as far as I understand it is the dataadapter that handles the update of the database, but it looks rather that it only updates the dataset and not the database
He who laughs last is a bit on the slow side
|
|
|
|
|
No, the DataAdapter is an Interface between the Dataset and the Database.
The DataSet is like a collection of your DataTables, which are Tabes in your virtual Database (Dataset)
You can work during 1year on the Dataset and after 1year you commit (update) all to the database.
The Dataset is designed to speed up the work with a DB.
Because your DB could be in another country, with a 56K Connection.
You tried already to step into the functions ( with help of Breakpoints and F10-Key ) ?
Or call the Update() into a try-catch ? It's possible that an exception is fired.
|
|
|
|
|
Yes, I have it in a try catch and step it through, no errors, it updates the grid with the changes and all the new fields added, but not the database.
Here's the code to the update
private void productsBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
try
{
this.Validate();
this.productsBindingSource.EndEdit();
this.productsTableAdapter.Update(this.productsDataSet.Products);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error");
}
He who laughs last is a bit on the slow side
|
|
|
|
|
Sorry, but i cant imagine what is the error.
You can create a very simple project, fill all data to the DataTable, change one record and
make the Update to the DB ...
On a very small project you don't have a huge number of possibilities where the error can be hidden
|
|
|
|
|
That's the problem, I don't receive an error, it does through as if everything was 100, but thanks for all your help, really appreciated.
He who laughs last is a bit on the slow side
|
|
|
|
|
After the Update you need to update the dataSet to reflect changes. To do this add the following after you update the dataAdapter:
dataSet.AcceptChanges();
Hope this helps.
Mike
Started out with nothing and still have most of it left!
|
|
|
|
|
Added that line
private void productsBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
try
{
this.Validate();
this.productsBindingSource.EndEdit();
this.productsTableAdapter.Update(this.productsDataSet.Products);
this.productsDataSet.AcceptChanges();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error");
}
}
But still no effect on the database, the dataset gets updated but not the database
He who laughs last is a bit on the slow side
|
|
|
|
|
Hmmm
The only other thing I can think of is that the EndEdit is used in wrong context...see code snippet below.
//If current item is not new and not cloned
if (!obj.IsNew && !obj.IsCloned)
{
drv = dvItem[index];
drv.BeginEdit();
}
else
drv = dvItem.AddNew();
//Transfer Shape data to DataView
obj.ObjectToDRV(drv, id);
drv.EndEdit();
daShape.Update(dsShapeEd1);
dsShapeEd1.AcceptChanges();
You'll notice that I only use the EndEdit if the object is being updated and not new!
Hope this helps.
Mike
Started out with nothing and still have most of it left!
|
|
|
|
|
It is as if the data adapter doesn't commit the changes to the database and then performs a roll back, but I can't figure out how to commit it to the database
He who laughs last is a bit on the slow side
|
|
|
|
|
Hi Friends,
I think this is my third post but still I couldn't get required reply. Hope to get this time.
I am developing a website to watch online movies. User needs to call a number to view movie (A company provide service to check whether user is connected to line or not They will call a script that will save or delete record in the database when user connects or disconnects phone line).
The only think which I need is that I need to run a script that checks database after every 5 or 10 seconds whether user record exists or not. I know it is possible to 'Refresh' page after certain time but my client doesn't want to do like this. I am using c# and Access database for this. I am struggling in it so waiting desperately for your reply.
Regards,
Abubakar Malik
|
|
|
|
|
Abubakar - I already posted how to do this here. Clickety[^] I showed you the javascript there, and explained what else you would need to do, i.e. use Ajax, so why have you posted a question about this again? If you needed more information, you should have replied to that post and not started another one off.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
hi all,
how to make a custom control in a desktop application using c#
which i need to prevent a user from writting integers in a textbox
thanx
|
|
|
|
|
1. Add a "Key Press" event for the text box.
2. And add the below code in the Key press function
if(!char.IsLetter(e.KeyChar))
{
e.Handled = true;
}
This solution ll help you not to enter any integers in the text box.
Thanks & Rgds,
Sri..
|
|
|
|
|
Thanx alot
this code helped me very much
thnax again
|
|
|
|
|
I have a UserControl that contains a collection of custom controls that inherit from Panel. I have configured an ActionItem to display the collections dropdown list (which opens the collection editor when clicked). I also have an ActionItem (property) which displays the current count of the collection. Everything works OK and I can Add and Remove items using the collection editor and the count field gets updated. However, when I create a designer for the child control, which inherits from ParentControl designer you get this stange problem. Adding controls using the SmartPanel option updates the count OK. Removing controls the first time updates the count OK. After that the SmartPanel will refuse to refresh. Calling the DesignerActionUIService.Refresh() method has no effect....I am stumped! If I change the designer to inhertit from ControlDesigner instead of PareControlDesigner it works fine but I need to be able to add controls at design time....help anyone?
Alans
|
|
|
|
|
There have two form which is form1 and form2.
In form1 user have to keyin the right password which we give them. If user keyin in teh textbox the password and click (OK button).If the password is same with the password we set.They can link to other form.
FOR FORM1:
private void textBox1_TextChanged(object sender,EventArgse)
{
// The password character is an asterisk.
textBox1.PasswordChar ='*';
// The control will allow no more than 4 characters.
textBox1.MaxLength = 4;
//
}
private void button1_Click(object sender, EventArgs e)
{
Form Other = new Form2();
Other.show();
}
*****What should I add in this two object so that:
1: In textbox keep user input
2: Verify in OK button object with our password to log in to form2.
TQ VERY MUCH.....
Email: krajah20@yahoo.com
|
|
|
|
|
I assume the following.
You want the user the enter the password in one form.
If the password, matches with some default/inbuilt/from the database password,
then it should go to the second form.
I also assume that you have a default password stored for comparison.
We'll Here it is.
You have to validate the password in the same form.
Form1 fm1 = new Form1();
Form2 fm2 = new Form2();
string DefaultPassword = "pass";
string PasswordCharacter = textBox1.Text;
if (PasswordCharacter==DefaultPassword)
{
fm2.Show();
fm1.Hide();
}
I hope this helps.
Keshav Kamat
India
|
|
|
|