|
The problem is your binding object is a DataTable and you are trying to add a record to the datagridview not the DataTable. Do something like below:
DataTable dt = dataGridView.DataSource;
DataRow dr = dt.NewRow;
dt.Rows.Add(dr);
Mike Lassetetr
|
|
|
|
|
Hi All,
What are the main differences between these two Interfaces and when we should prefer which one???
and shud we implement these in the same class in which we r comparing or shud we make a new calss for that......also i m having problem implementing IComparer interface when i implement this the compiler gives this error
The type or namespace name 'IComparer' could not be found (are you missing a using directive or an assembly reference?)
so plz tell me also wots the solution of this
Looking forward for help
Regards,
-- modified at 12:38 Tuesday 23rd May, 2006
|
|
|
|
|
IComparer is defined in System.Collections. Thus you need to add using System.Collections; at the top of your code.
IComparable must always be implemented by the the class which should be sorted. IComparer should be implemented in separated classes. You should go with IComparer if you want to sort your objects by different criterias (e.g. by its name, some associated values...). Because IComparer can be separated from the class to be sorted you can have as much implementations as you like.
|
|
|
|
|
|
I'm trying to code an MDI windowing system where the names of the child windows are placed into a menu system at startup time. The problem that I'm having is how to invoke the child windows (from a string variable) after an option has been selected. I have thumbed through a lot of paper work on reflection but nothing really seems to match the requirment
Any Ideas guys
|
|
|
|
|
Did you try Activator.CreateInstance[^]
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
www.troschuetz.de
|
|
|
|
|
Hello All,
I make two forms First is Login Form and second is "Change Password" form, when change password form opens here two fields are showed one for OldPassword and other for NewPassword, now my intension is that how i can update an old password
in the database (i'm using MSAccess database) tell me the command of Update even i know this command and also apply it but it dosen't work, it gives me error "Syntax error in UPDATE command" on runtime.
plz assist me in this way.
m.reehanmunir
|
|
|
|
|
that means there is a syntax error at the query string..
just show code and maybe there would be some help..
good coding
|
|
|
|
|
"this is my code now plz help me according to this" here "password" is database field;" thx
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\C#Projects\\practice1\\SMSDB.mdb;Persist Security Info=False");
con.Open();
string updata = "update SMSDB set password= '"+txtnewpwd.Text+"' where password='"+txtoldpwd.Text+"'";
OleDbTransaction tx = con.BeginTransaction();
tx.Commit();
OleDbCommand cmd = new OleDbCommand(updata,con);
cmd.ExecuteNonQuery();
con.Close();
m.reehanmunir
|
|
|
|
|
An example of what you are doing will be helpful. Did you remember to put quotes around the passwords?
It should look something like this:
UPDATE usertable SET password = 'newpassword' WHERE password = 'oldpassword';
When creating the UPDATE string, you will need to surround your password variables with the single quote. That is the only thing I can think of which may be causing the problem.
I sometimes find it helpful to use a SQL Editor for creating my SQL statements. It saves me a bunch of time from having to try and retry different commands through code. I don't use MSAccess so I am not sure what type of GUI editor they may have.
|
|
|
|
|
"This is my code now plz help me according to this code" here "password" is the field of database;"
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\C#Projects\\practice1\\SMSDB.mdb;Persist Security Info=False");
con.Open();
string updata = "update SMSDB set password= '"+txtnewpwd.Text+"' where password='"+txtoldpwd.Text+"'";
OleDbTransaction tx = con.BeginTransaction();
tx.Commit();
OleDbCommand cmd = new OleDbCommand(updata,con);
cmd.ExecuteNonQuery();
con.Close();
m.reehanmunir
|
|
|
|
|
It is not necessary to create a transaction. Transactions are used when you plan on doing several SQL calls and there is the possibility of a problem. If there is a problem, a transaction lets you rollback any change prior to anything being fully committed to the database.
In the case of the password, you have the one SQL statement and probably do not want it in a transaction. If you did want a transaction, the commit will need to be AFTER your Execute call. As it is, the Transaction in the code is not doing anything and can probably be removed.
Try putting a space between password and the '='.
|
|
|
|
|
Hi.
I am extracting fields from a FoxPro database.
For reasons that I won't go into, one of the character fields contains an array of 4 characters.
The first character is almost always a Unicode-null.
Now .. When I read this field using a System.Data.DataRow .. it thinks the field is a blank string (String.Empty).
This is because, a string variable is basically a character array, terminated by a unicode-null value.
My character array is therefore immediately terminated (as the first character is a null character).
How on earth do I extract these field values?
I can do this in VBA (in Access) using the same connection string. It returns a string of the individual unicode characters ... but in .Net (both C#.Net and VB.Net) I get returned a blank string.
HELP ?
My Code<br />
OleDbConnection _connection = new OleDbConnection( @"Provider=VFPOLEDB.1;Data Source=C:\DataFolder\;");<br />
<br />
string strSelect = "SELECT * FROM table1";<br />
<br />
OleDbDataAdapter _dataAdapter = new OleDbDataAdapter(strSelect, _connection);<br />
OleDbCommandBuilder _commandBuilder = new OleDbCommandBuilder(_dataAdapter);<br />
DataSet _dataset = new DataSet();<br />
<br />
_dataAdapter.FillSchema(_dataset, SchemaType.Source);<br />
_dataAdapter.Fill(_dataset);<br />
<br />
foreach(DataRow dr in _dataset.Tables[0].Rows)<br />
{<br />
object thisField = dr["myField"];<br />
}<br />
<br />
<br />
string myStr = "Hello World";<br />
<br />
char myChar = Convert.ToChar(0);<br />
<br />
myStr = myStr.Replace("l", myChar);<br />
<br />
Console.Writeline ( myStr );<br />
<br />
Any help would be appreciated.
Thankyou
MKeeper
"imagine how stupid the average person is ...
now imagine that half the planet is more stupid than that!"
|
|
|
|
|
There is a language called Lua. It is script writing for video games.
I want to be able to define syntax rules, compilation, intellisense, etc..
here is an example program I found
http://www.wowinterface.com/downloads/info4222-WoW_UI_Designer.html[^]
Would I make an add in to define rules for the language inside the IDE? Any links or pointers would be great.
Thanks,
Nick
1 line of code equals many bugs. So don't write any!!
-- modified at 10:47 Tuesday 23rd May, 2006
|
|
|
|
|
we have a web app which uses a class library. and that class library holds all the DB calls. in each DB call in the class library, there's a little section that grabs the DB connection string, like this:
<br />
string connString = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;<br />
SqlConnection conn = new SqlConnection(connString);<br />
works fine.
i now need to make a console app which uses some of the DB stuff from the class library. so, i make a console app project, add a reference to the class lib, and etc.. it builds fine. but when i run it, when it gets to the lines above, it dies because ConfigurationManager is null. so, i guess it's not initialized.
my questions:
1. where is ConfigurationManager initialized in a web app?
2. how does the class library know about it?
3. why doesn't that happen in a console app?
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Add a config file to your console app and put the connection strings in there
1 line of code equals many bugs. So don't write any!!
|
|
|
|
|
yes, i know.
but the problem is that the ConfigurationManager isn't visible globally in the console app, as it is in the web app. so, even if the ConfigurationManagerdoes have the connection string, the DB code can't get to the ConfigurationManager.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
right click project -> Add References
Scroll down to System.Configuration
Click OK
Its now accessible
1 line of code equals many bugs. So don't write any!!
|
|
|
|
|
|
|
Actually, I think your problem is real simple. It's just that you didn't get the config file where it needed to be. You can add an app.config to your project, but it doesn't do anything for you until it's copied out to the directory where your .exe is and renamed. Like my exe is TestConfigManager.exe, so I have to copy my app.config out to where that is and rename it to TestConfigManager.exe.config. I usually just write a postbuild to handle it.
www.logifusion.com
|
|
|
|
|
you're exactly right.
i was assuming the documentation for ConfigurationManger.OpenConfiguration (or whatever that member is called) allowed you to specify the config file you wanted to use. apparently, it doesn't. once i renamed, and changed that call to use the EXE's name, it all worked.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
If you add the configuration file to the project via VS .NET (Application Configuration File), then it does the copying for you.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Greetings:
I am looking for a way to embed the date and time of the build of my Visual Studio 2003 C# application. That is, I would like to have some strings in my code that are automatically set at build time with the system date time and will provide me with an easy way to display the build date and time in an "About" box at run time.
Thank you in advance,
Mark
-- modified at 9:53 Tuesday 23rd May, 2006
|
|
|
|
|
As far as I know, you can only get the creation time. There are no embed datetime in file.
FileInfo fi = new FileInfo(Process.GetCurrentProcess().MainModule.FileName);
MessageBox.Show(fi.CreationTime.ToString());
|
|
|
|