|
Then instead of Hasrow,use like this
replace the below code
if (dr.HasRows == false)
{
}
new code
if (!dr.Read())
{
MessageBox.Show("No records");
}
else
{
MessageBox.Show("Records Found");
}
Regards,
Karthik K...
|
|
|
|
|
Sir When I Use Ur Above Coding In my Aplication show error
Error Is
'Microsoft.Data.Odbc.OdbcDataReader' does not contain a definition for 'HasRows'
|
|
|
|
|
mjawadkhatri wrote: No I not tried to implement any thing.
Why not.
What are you going to run the select against, a List<> or datatable/view. You can use Linq or Rowfilter for the first part and the second is standard CRUD work.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
i want to do Accept employee ID in one time in a day 2nd time user give same Id in a same date not accepted.
this is my coding
string MyString;
MyString = "Select * from timemgmt";
if (radioin.Checked == true)
{
cn = new OdbcConnection("Driver={Microsoft ODBC for Oracle};Server=orcl;UID=it;PWD=cr;");
cmd = new OdbcCommand(MyString, cn);
cn.Open();
cmd.CommandText = "insert into timemgmt values('" + textBox1.Text + "','" + label19.Text + "','" + label18.Text + "','" + label18.Text + "')";
cmd.ExecuteNonQuery();
cn.Close();
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
textbox1.text = employe ID
label19.text = System Date
label18.text = System Time
|
|
|
|
|
You need to read this article on SQL Injection[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
If a text file is there on desktop.
How to print that file using one of the printer installed in my system.
How to set the printer settings?
At first how can we access the printer?
|
|
|
|
|
|
Hi
I want a method which gives an object for each and every instance of Internet Explorer, such that I can catch the text of the web page displayed in IE. I want to catch that text before it displayed on screen.
How to do?
|
|
|
|
|
Hello all,
I have created an "User Control" and using it around 10times on the same page, displaying 10 different datasets it works fine.
Now I have a button on the same user control and have to generate a number from [ 1 to 10] each time to know on what control the button click event has happened [Say for example when user click on "User Control-1, button the click event has to generate 1, if he click on "User Control 2" button, 2 has to be generated and so on..]. I don't know how this can be achieved.
How is this possible.....any help is greatly appreciated.
Thank You
Bye.
|
|
|
|
|
IMO you should have a delegate and handle the button click event in the parent form. Or in the button click event, check for the parent control and execute code accordingly. Something like this:
switch(button.parent.tag){
}
For this, you will need to set the tag property of the usercontrol in the form.
|
|
|
|
|
Iam new to Asp.NET/C#. I know how to define a delegate and use event, but how I can use them in this case is confusing me. Can you elaborate little more on this.
Thank you very much.
|
|
|
|
|
Place this code in the user control. Here ClickOKButton handles click event of the button in the user control.
public event EventHandler OkButtonClick;
protected void OnOKButtonClick(EventArgs e) {
if (OkButtonClick != null) {
OkButtonClick(this, e);
}
}
protected void ClickOKButton(object sender, EventArgs e) {
OnOKButtonClick(e);
}
Now, when you add your control to the form, it will expose OkButtonClick which can be handled in the form itself. Like this:
YourUserControl.OKButtonclick += new EventHandler(SomeMethod);
|
|
|
|
|
Thank you d@nish,
I did it in a different way, I have added a property to my user control and then setting that property on every usage of the user control on the page and in the button click using that property able to know which controls button has been clicked.
|
|
|
|
|
cmd.CommandText = "UPDATE Vendor SET VendorId ='" + txtDate.Text + "',VendorFName ='" + txtFName.Text + "',
VendorLName ='" + txtLName.Text +"',VendorCity ='" + txtCity.Text + "',VendorState='" +
txtState.Text+"',VendorCountry='"+ txtCountry.Text+"',VendorDescription='"+txtDescription.Text+"' )";
i got an error message while update a gridview that "object reference not set to an instance of an object"
|
|
|
|
|
That's not the worst of your problems.
A) Step into the code with the debugger and find out what is null.
B) Then completely rewrite your code. Use parameterized SQL command.
|
|
|
|
|
You are Doing String Concatination. The only thing that might cause this error is the "cmd" if you dont hava a statement above this code that says
SqlCommand cmd = new SqlCommand();
then that is a problem, because the incorect string concatination will not give this error descritption
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Hi,
I'm a C++ programmer looking to learn C#, I have no experience with .NET, I bought "Essential C# 2.0" a few years back but never got a chance to read it.
Could somebody recommend a good C# book, preferably using the .NET 3.5 framework - these three all seem to be well rated so I don't know which (if any) to choose:
Apress - Pro C# 2008 and the .NET 3.5 Platform, Fourth Edition
Wrox - Professional C# 2008
C# 3.0 in a Nutshell: A Desktop Quick Reference
Thanks in advance for any suggestions.
|
|
|
|
|
321Markus123 wrote: Wrox - Professional C# 2008
-- I have an older version (from 2003) that I had to buy for a class way back then, it seems pretty good.
|
|
|
|
|
Hello people,
Is it posible to declare the type of a generic at runtime?
I mean, you normaly would have to do something like this:
GenericMethod<Type>();
And I want to do something like this:
GenericMethod<(expression that evaluates to a type)>();
I have tried a few things but nothing seems to work.
MSDN's C# Programming Guide states that:
"client code must declare and instantiate a constructed type by specifying a type argument inside the angle brackets. The type argument for this particular class can be any type recognized by the compiler."
Thanks!
|
|
|
|
|
You could always use a Func here. For instance:
GenericMethod<Func<T, TResult>>();
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Thanks Pete,
And what exactly would this Func be or do?
Thanks again!
|
|
|
|
|
This[^] article should help. This type of functionality is the mojo behind Linq.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Good link Pete, very concise.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Thanks Pete, I read your link and it seems this particular feature it's not for C# 2.0, which is preciselly the version i'm working
|
|
|
|
|
What kind of expression that evaluates to a type would you have there? Something with reflection? You could probably use reflection to invoke the method with an expression of the type Type , but I'm not actually sure. Reflection can do a lot though, so why not..
edit: If all else fails, there is still the possibility to compile and run a piece of code that has been generated at runtime. But I wouldn't use that except in emergencies. It's not exactly fast, or a clean design.
|
|
|
|