|
The way you're doing it is not optimal and often leads to problems because certain characters - like quotes - are not escaped properly. See the documentation for the OleDbParameter class and use a paramterized query like so:
OleDbCommand cmd = myConnection.CreateCommand();
cmd.CommandText = "UPDATE userinfo SET Password=? WHERE " +
"Name=? AND Password=?";
cmd.Parameters.Add("NewPassword", OleDbType.VarWChar, 40).Value = newPassword;
cmd.Parameters.Add("Name", OleDbType.VarWChar, 40).Value = user.Name;
cmd.Parameters.Add("OlePassword", OleDbType.VarWChar, 40).Value = oldPassword;
int i = cmd.ExecuteNonQuery();
Console.WriteLine("{0} record(s) modified", i); The OLE DB provider for ADO.NET does not use named parameters, and instead uses positional parameters using the question mark, so you must add your parameters in the same order. The example aboves assumes you declare your fields as Text using 40 characters as the length. This is just an example, though, so read the documentation for the OleDbParameter for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi there,
How can i dynamically read :-Othe SMTPSERVER NAME from my local network.
hai, feel free to contact.
Sreejith SS Nair
sreejithssnair@hotmail.com
|
|
|
|
|
The only method I know of is to search a range of IP addresses by 1) pinging the address to see if it's alive, then 2) try opening a connection to port 25 on that address. If you get response, you've probably found the SMTP server. Most telecom guys will come down and beat on you for port scanning their network though...
SMTP servers don't "advertise" their presence on the network, so scanning for it the only method to find one automatically.
The better option is to ask the user what the DNS name of the server is or set it in a configuration file.
RageInTheMachine9532
|
|
|
|
|
How to get the IP of SqlServer?
Can you help me?
Jiw
|
|
|
|
|
I'm curious as to why you want the IP address of the SQL Server.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
|
|
|
|
|
Because i want to copy files to server,but i don't know how to get the Path.
|
|
|
|
|
Getting the IP of the Server will not get you the path... The IP and ServerName are completely interchangable in paths:
\\xxx.xxx.xxx.xxx\share\dir\dir\dir\file
is exactly the same as:
\\servername\share\dir\dir\dir\file
since the system will resolve the servername to it's IP address for you, automatically...
RageInTheMachine9532
|
|
|
|
|
If you know the host name already, you can use Dns.GetHostByName to get the IPHostEntry , from which you can get the IP address. You really don't need it for ADO.NET, though. Just use the SQL Server name and instance (if any besides the default instance).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
dear there,
i have a dataset with a table.I need to bind this untyped dataset to a datagrid.
on runtime i need to show i record number along with records.
That is serial number to every record in datagrid
hai, feel free to contact for any support provided that must be my level of knowledge
Sreejith SS Nair
sreejith@neosoft-tec.com
|
|
|
|
|
Without owner-drawing the DataGrid (which could be pretty difficult), you could extend DataGridColumnStyle with a row that displays an incremental value. Use the DataGrid.TableStyles to add a DataGridTableStyle that has the columns you need, including your DataGridColumnStyle derivative that displays the row number as the first column (or wherever you want it). If you allow sorting and what the row indexes to keep in sync, then you'll need to add a little intelligence to your DataGridColumnStyle derivative that uses the row's index in the DataTable . See the documentation for the DataGridColumnStyle for more information and an example.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi everybody!
Ijust started studing programming in C#. I so in some source code they are using namespaces: Microsoft.DirectX, Microsoft.DirectX.DirectSound. I'm using .NET 2003 and I thought that I had all libraries, but my namespace Microsoft has only CSharp,VisualBasic and Win32 libraries.
Question: where I can get, or how I can reference Microsoft.DirectX?
I also have question about saving image when it was loaded into pictureBox from file using
image.fromFile(...) function,if I want to save it in the same file and use image.save(...) function passing same file name, i'm getting error msg that file is used by another program(apparently fromFile() did not close file, and I have no handle to this file to close it).
Question: Is there a way to save it into the same file?
And last question: If I downloded image (jpeg) as a bitmap
can I select some polygones on image and change its colors
dynamicaly?
Thanks
|
|
|
|
|
For the first question:
You must download the DirectX SDK 2003 summer update.
You can obtain it here:
http://www.microsoft.com/downloads/details.aspx?FamilyID=9216652f-51e0-402e-b7b5-feb68d00f298&displaylang=en
As for the second: you can copy the image from a PictureBox to a temorary BitmapImage object and then dispose the PictureBox, and then save the image.
For the tthird; you mean pixels, right? I know it can be done, but I am not shure if it can be done directly on the PictureBox object. Maybe someone else will anwser you this question ...
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
You could also Clone the image, then save it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Any tutorial on regular expressions is likely to use this as an obvious example.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
hi,
I'm new in C# programming, I created an array using ArrayList.Add() function to insert that structure in the array
<br />
public struct LineToCheck<br />
{<br />
public string fileName;<br />
public ulong CRC;<br />
public LineToCheck(string filename,ulong CRC)<br />
{<br />
this.fileName=filename;<br />
this.CRC=CRC;<br />
}<br />
}<br />
my question is........how I access to that structure from the array???
I tryied to use array[0]. but I can't see structure... I can't also understand how to use the array.ToArray() function..... since I don't use int or chat array.... thanks in advance
Paolo
|
|
|
|
|
Because there are no templates, your container has no idea what it contains, it just knows it contains objects ( because everything is an object ). So, in order to use what is in your array, you need to do one of two things:
1. Contain an ArrayList in a class called LineToCheckArrayList, or whatever, so that it's access methods are strongly typed
2. Cast the return from the ArrayList every time you use it. To be really correct, you should us the 'as' keyword ( i.e. array[0] as LineToCheck, not (LineToCheck)array[0] ), which will not blow up, but return null if the object is not of the type you expect. Obviously, this is not a good idea unless you intend to check the type yourself. You can use the 'is' keyword for this, as in if(item is LineToCheck).
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
:-Dusing System;
//namespace for ArrayList
using System.Collections;
namespace ArrlistVSStruct
{
//your struct signature
public struct LineToCheck
{
public string fileName;
public string CRC;
public LineToCheck(string filename,string CRC)
{
this.fileName=filename;
this.CRC=CRC;
}
}
class Class1
{
static void Main()
{
//Arraylist creation.
ArrayList Arlist=new ArrayList();
declaring three variable of the type LineToCheck
LineToCheck LC1,LC2,LC3;
//assigning values to struct
LC1=new LineToCheck("ha ha","hi hi");
LC2=new LineToCheck("hey hey","ho ho");
//adding to arraylist
Arlist.Add(LC1);
Arlist.Add(LC2);
//getting the values out
for(int i=0;i
|
|
|
|
|
I seen on msdn that you can use the setup.exe bootstrapper to make a setup program detect if the dotnetfx framework is on the current computer and if its isn't it will install dotnetfx.exe. That sounds wonderful. I just don't see anything on there about actually how to do it. I tried using the setup wizard its just not clear to me. If i really knew a keyword to search for or something that would be great.
I have my project complete and would like to distribute it but I don't need my clients searching all over the internet for the dotnet files. I want it to install everything they need. if there is a good tutorial on using the setup wizard that would be great and please DON'T DIRECT ME TO MSDN that site might be great but in all honesty i go in there trying to learn how to write my name and by the time i get done reading i've done forgot the alphabet.
Win32newb
"Making windows programs worse than they already are"
|
|
|
|
|
The bootstrapper is a program that checks for the .NET Framework installed on the machine running your setup .MSI. If it is not there, the bootstrapper launches the install dotnetfx.exe to install the framework. If it is there, then it simply launches the .MSI Installer for your app.
You might want to look at the GotDotNet Bootstrapper Plugin workspace here[^].
RageInTheMachine9532
|
|
|
|
|
First, some actual resources for those willing to learn to research
Read This
Now step by step:
Read the article called "Using Visual Studio .NET 2003 to Redistribute the .NET Framework"
Download the plugin for VS 2003
NOTE: You will not notice anything visibly different with your installs. There's no pretty wizard or anything.
However, when you compile your application you will notice that the setup contains the dotnetfx.exe file in it as well as a few others. You can zip up the whole lot of 'em and just have users run setup.exe
Of course by doing this your distribution size just grew by 23 megs or so...
--Tony Archer
"I can build it good, fast and cheap. Pick any two."
|
|
|
|
|
Hi,
When I bind a textBox control's text property to a DataSet, it works well. But when I use
this.BindingContext[dataSet11.tbl_name].Position++(--) set the postion , the textBox control can't update the content. Would you please tell me how to solve the problem.
In addition, if I bind the same dataset to a listbox control, and use mouse to select the listed item, the textbox's content can change. Why????????
Thank's a lot!!
Alan Shen
|
|
|
|
|
When using the BindingContext , you must use the same data as you bound against. If you bound to the DataSet itself, then don't use tbl_name (whatever that is supposed to represent; hopefully the strongly typed DataTable in a typed DataSet ).
If you use the same binding context that the control is bound to, simply incrementing or decrementing the BindingManagerBase.Position will update the data in the data-bound controls bound to that binding context.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks a lot!!
And there is another question.
if I use the following two clauses, the data-bound control can not update.(Because I am using two different BindingContext objects)
1. this.textBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "Test.id"));
2.this.BindingContext[dataSet11.Test].Position --;
But if I change 1 to 3, the control can update itself.
3.this.textBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11.Test, "id"));
Why????
I am still using two different BindingContext objects.
|
|
|
|
|
No you're not, actually. Both 2 and 3 bind to dataSet11.Test , where 1 binds against dataSet11 . That's the difference.
Microsoft MVP, Visual C#
My Articles
|
|
|
|