|
Thanh you very much.
Today i have a example so that I am very your help.
My Code is very dirty.
But I will send you.
Step1. I create A class ClsLogin in a file : "lsLogin.cs"
<br />
public class ClsLogin<br />
{<br />
public string userName;<br />
public string passWord;<br />
public static SqlDataAdapter SQLDataAdapter;<br />
public static DataSet ODataSet;<br />
public SqlCommand sqlcom;<br />
public SqlCommandBuilder sqlBuilder;<br />
}<br />
Step 2.I Create a Class User in a file: "ClsUser.cs"
<br />
public class ClsUser<br />
{<br />
public ClsUser()<br />
{}<br />
public DataSet FillUser()<br />
{<br />
ClsLogin oClogin = new ClsLogin();<br />
ClsLogin.SQLDataAdapter = new SqlDataAdapter("SELECT * FROM tbl_Employee",ClsConnection.SQLConnection);<br />
ClsLogin.ODataSet = new DataSet();<br />
try<br />
{<br />
ClsLogin.SQLDataAdapter.Fill(ClsLogin.ODataSet,"User");<br />
<br />
oClogin.SQLCOMBUILDER =new SqlCommandBuilder(ClsLogin.SQLDataAdapter);<br />
ClsLogin.SQLDataAdapter.Update(ClsLogin.ODataSet.Tables[0]);<br />
return ClsLogin.ODataSet ;<br />
<br />
}<br />
catch(Exception ex)<br />
{<br />
throw ex;<br />
return ClsLogin.ODataSet;<br />
}<br />
}<br />
}<br />
Step3. i binding data to Datagrid in my form in file: "MyWindfor.cs"
<br />
private void btnLoad_Click(object sender, System.EventArgs e)<br />
{<br />
this.CheckLoad();<br />
}<br />
private CurrencyManager oCm;<br />
private DataSet oDs;<br />
private void CheckLoad()<br />
{<br />
<br />
ClsUser oUser =new ClsUser();<br />
try<br />
{<br />
oDs = oUser.FillUser();<br />
this.dataGrid1.DataSource = oDs.Tables["User"];<br />
this.oCm = (CurrencyManager)BindingContext[oDs.Tables[0]];<br />
}<br />
catch(Exception ex)<br />
{<br />
MessageBox.Show("Lỗi sảy ra: " +ex.Message +":"+ex.Source);<br />
}<br />
}<br />
. Finish to Here is Success. Data in DataBase displayed in Datagrid if click btnLoad.
***** But my Problem is:*****
I have a button : name = btnDelete in file "MyWindform.cs". And I writed code to delete a row in dataset, after I want update dataset to "Database" As.
<br />
private void btnDelete_Click(object sender, System.EventArgs e)<br />
{<br />
ClsLogin.ODataSet.Tables[0].Rows.RemoveAt(this.oCm.Position);<br />
ClsLogin oLogin =new ClsLogin();<br />
<br />
oLogin.sqlBuilder= new SqlCommandBuilder(ClsLogin.SQLDataAdapter);<br />
ClsLogin.SQLDataAdapter.Update(ClsLogin.ODataSet.Tables[0]);<br />
<br />
}<br />
Then you Click btnDelete: a Row in table of Dataset deleted. But Data Datasource don't Update. Didn't change.
Help Me.
|
|
|
|
|
is your dataset typed dataset ??
Tamimi - Code
|
|
|
|
|
What do typed DataSet effect in my Code?.
I don't know about type DataSet.
I am honest thank your help.
Thank to your care.
|
|
|
|
|
Hi,
I'm displaying a jpg file in a Panel control with a "stretch to fit" option. When I start resizing the form that owns the panel the image resizes with it, but it flickers and it's really annoying. Is there a way to eliminate this?
thanx
|
|
|
|
|
Use the SetStyle method to turn on double buffering.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
I've already tried this, but I can only call SetStyle on the form containing the panel. The flicker is still there, though.
|
|
|
|
|
The Panel needs to be double buffered. If you can't call SetStyle externally, derive a class from Panel and try that
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Just tried it.. same thing.
|
|
|
|
|
Found the problem: I need to set AllPaintingInWmPaint as well. So it's like this:
SetStyle(ControlStyles.UserPaint,true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.DoubleBuffer,true);
thanx
|
|
|
|
|
i want to know how to get the serial number of motherbord ,harddisk,etc with c# code
|
|
|
|
|
Windows Management Instrumentation (WMI)
|
|
|
|
|
As someone else said, WMI. The problem is, you'll find you can't access it unless your user is admin.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hello omar,
I think this is usefull to u.
-- modified at 6:48 Friday 18th August, 2006
regards,
Divyang Mithaiwala
System Engineer & Software Developer
|
|
|
|
|
I wrote a program for my company that uses the SQL MSDE. I would like to know what class/function to use to retrieve the SQL server instance, computer name, and the path for the current users My Document folder. I will use this information to create the connection string on the fly. Is that a good idea or bad programming practice? If it is bad, what is an alternative?
Also, whats a good/free installer program I can tinker with?
Thanx in advance!
Jude
|
|
|
|
|
It's something like Enviroment.GetSpecialFolder to get the My Documents folder ( among others, it takes an enum ).
Advanced Installer has a free version, I've found it quite good.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Was that a point to do my own work or are you not sure??LOL...Thanx!
Jude
|
|
|
|
|
*grin* I was flat out and going from memory. That should be enough for you to find it, if not, just give me another yell.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanx brother..but about getting that info to do on the fly sql connections...good programming practice or not?
UPDATE
I looked at MSDN Library and got this:
[C#]
// Sample for the Environment.GetFolderPath method
using System;
class Sample
{
public static void Main()
{
Console.WriteLine();
Console.WriteLine("GetFolderPath: {0}",
Environment.GetFolderPath(Environment.SpecialFolder.System));
}
}
When I try to type Environment.SpecialFolder, Intellisense does not pop up..is this a valid property in C#? If so, what do I add to it?
Thanx
EDIT
Ok, got it..a environment class and enum
-- modified at 23:34 Wednesday 16th August, 2006
-- modified at 23:41 Wednesday 16th August, 2006
-- modified at 16:19 Thursday 17th August, 2006
Jude
|
|
|
|
|
A client recently asked me if I could make a porgram that would have a fairly simple functionality, but with a catch.
When the program is running he wants it to be the only program available. So a user couldn't alt tab and go to another program or minimize the program and open up a web broswer. To get out might require the user to hit escape and type in a password.
I call it "Locking" but maybe there's already a phrase for this type of functionality. Is there?
Drathmar
|
|
|
|
|
The program could make itself topmost, I guess. It could also grab the input focus whenever it loses it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
This could be done, but it is better left to Group Policy to do this. There are LOTS of ways to get around this "lock", and your app won't be able to cover them all.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
When you say to leave it to Group Policy? I don't exactly follow, how would you do this with "Group Policy"?
|
|
|
|
|
Pick up the Windows XP Resource Kit and you'll find out. It's covered in about half of the book. But, to give you a quick look-see, click Start, Run, then type gpedit.msc and Hit enter.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dear gurus
I have a question to generics at the following code
<br />
class ABC <br />
{<br />
<br />
void fkt<T>(T x) {<br />
double y = (double)x; <br />
}<br />
<br />
}<br />
I get the errormessage: Cannot convert Type 'T' to 'double'.
This is absolutely clear ( the compiler does not know if the conversion is possible and therefore it provides this errormessage ).
My Question is:
In my application T is either 'Int32' or 'Double'. How can I convince the compiler to compile this code for my issues (int32 and double where conversion is in fact possible)?
With kind regards
|
|
|
|
|
You have to specify a constraint that says T is is convertable to a double otherwise there is no way to know if X can be converted to a double.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|