|
You can use it. But make sure you specify in the connection string, that the database type is access.
Can you print out the sql in your c# program, log onto access, and try to run the same update statement in access.
|
|
|
|
|
string sqlSelect = string.format("UPDATE Users_Table SET Password= '{0}' WHERE Username='{1}' AND Password='{2}'",txtNewPassword.Text.ToString(),txtUsername.Text,txtOldPassword.Text);
command.CommandText = sqlSelect;
you can also try like this.
|
|
|
|
|
First and foremost, you do NOT use string concatentation to built a query like that. Why? Just Google for "SQL Injection attack" and you'll find out. A big problem with what you've done is what happens if the user types a ' character in their password?? I guarantee that it'll break your code and give you the error that you're talking about.
Then you can Google for "C# SQL Parameterized queries" to find out how to do it correcly. This also has the benefit of making your code easier to debug and maintain.
Next, why are you calling .ToString() on a string?? The Text property always returns a string, so there's no need to call .ToString() on it!
And finally, with an UPDATE statement as yours, you would normally use ExecuteScalar, no ExecuteReader, to launch it.
|
|
|
|
|
Now i have prevent my access database from injection??
I have the same error yet.
OleDbConnection connect = new OleDbConnection();
connect.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\user\Desktop\Laiki_Trapeza_Questionnaires.accdb;Persist Security Info=False;";
connect.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connect;
string OldPassword = txtOldPassword.Text;
string Username = txtUsername.Text;
string Password = txtNewPassword.Text;
command.CommandText = (@"UPDATE Users_Table SET Password=@Password WHERE (Username=@Username AND Password=@OldPassword )");
command.ExecuteReader();
MessageBox.Show(" Succesfull update password!");
connect.Close();
modified 11-Mar-13 17:32pm.
|
|
|
|
|
Yeah, you never supplied the values for any of the parameters. Keep reading those links. You might want to pick out stuff that mentions "OldDbParameter".
|
|
|
|
|
what did you mean ? these commands must become
string OldPassword = txtOldPassword.Text;
string Username = txtUsername.Text;
string Password = txtNewPassword.Text;
like this:
command.Parameters.AddWithValue(@"OldPassword", txtOldPassword);
command.Parameters.AddWithValue(@"NewPassword", txtNewPassword);
command.Parameters.AddWithValue(@"Username", txtUsername);
????
sorry but i don't understand what you mean with Keep reading those links. You might want to pick out stuff that mentions "OldDbParameter".
modified 12-Mar-13 15:00pm.
|
|
|
|
|
Hi,
I am using WMI to make a call to an executeable on a remote server.
I have this defined in the managementpath, \\\\<servername>\\root\\cimv2:Win32_Process
My actual exe is located on the D drive of the same machine.
Is it required that this exe also be located on the C drive of the remote server????
Also, in the ManagementBaseObject class, method the InvokeMethod as a returnValue parameter. What are all the possible values for this parameter?
What value is returned if successful versus failed?
Thanks so much!!
modified 11-Mar-13 15:27pm.
|
|
|
|
|
Try reading the documentation on the Win32_Process class, Create method.Create method[^] for the return values.
If you're trying to run a process remotely that puts up a user interface, like Notepad for example, for the logged in user to see, you can't. It's a HUGE security risk, so WMI won't let you do it.
You CAN however run an executable that does NOT show any user interface, like a Console application.
You can launch the .EXE with the file being on your machine but ONLY if the .EXE file resides in a network share ono your machine. If you don't understand Windows Networking, just copy the .EXE file to the target machine and launch it from there. It's much simpler to do.
|
|
|
|
|
Awesome!! thanks, that is what I was looking for, in terms of what is returned in the returnValue parameter.
It is a console based application, which does NOT put up a user interface.
This works well!
|
|
|
|
|
How can I integrate open office impress in my C# windows form application.
I want to load a .ppt, .odp file and show it on my form using C#.
It's a presentation control app.
Any suggestion?
Thanks!
|
|
|
|
|
|
I'm using this SDK already.
but all the search tends to only format conversion or spreadsheet examples.
Not getting any way how to use Impress or presentation.
Do you have any idea?
Thanks!
|
|
|
|
|
|
Install the PowerPoint viewer[^] (it's free) and automate it. Don't bump your question.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I have a text file containing the following content:
0 12
1 15
2 6
3 4
4 3
5 6
6 12
7 8
8 8
9 9
10 13
the first column specifies the x coordinate of a point and second column specifies the y coordinate.i need to read this file and find slope between all points. like first i find slope between (0,12) and (1,15) and then between (0,15) and (2,6) and so on.i am basically building a wpf application.can anyone help?
|
|
|
|
|
The basic forumula for a slope is (y2 - y1) / (x2 - x1 ).
Since you have all the co-ordinates, you can put them into an array and then run a loop over the array.
You can also input them via a textbox on WPF.
|
|
|
|
|
i tried to put x and y coordinates in two different arrays but don't understand how to write a code that calculates the slope between points and displays them in a textbox.
i have written the following code snippet:
var r = File.ReadAllLines(path)
.Select(line => line.Split(' '))
.Select(arr => new
{
Column0 = Int32.Parse(arr[0]),
Column1 = Int32.Parse(arr[1])
})
.ToArray();
int[] column0 = r.Select(x => x.Column0).ToArray();
int[] column1 = r.Select(x => x.Column1).ToArray();
|
|
|
|
|
Try
for (int i=0; i<=column1.Count - 2;i++)
{
float slope = (column1[i+1] - column1[i])/(column0[i+1] - column0[i])
}
|
|
|
|
|
Shouldn't you cast at least one of the operands of the division to float then?
|
|
|
|
|
i'm getting 'divide by zero' exception here.what is the method to fix this error?
|
|
|
|
|
If (x2 - x1) is 0, the slope is infinity.
Handle this case in code. Check and make sure (x2 - x1) is not 0 by a simple validation condition.
|
|
|
|
|
I want to create a presentation controller or a power point viewer using C#.
I have completed this using microsoft office 2007, but I want to make it not compatible with
microsoft office(because it's licensed).
If there is no MS-office is installed, program should work. And there shouldn't be any licensed
compatibility with the app. And my budget is low to purchase a library.
Do you have any idea?
Please share your opinions.
Thanks!
modified 11-Mar-13 1:58am.
|
|
|
|
|
If it is just .pptx that you need then you can write your own - all the information required is in ISO 29500 which can be downloaded freely.
If your time is free then no problem, but if you are being paid for your time (this is going to be a lengthy project) buying a library may be more cost effective.
For .ppt files I'm not sure. I have previously used NPOI for .xls, it may do .ppt too, you would need to have a look.
|
|
|
|
|
Thanks for your reply!
NPOI doesn't control .ppt yet.
http://npoi.codeplex.com/discussions/405690[^]
it's for .xls only.
I just want to open a .ppt file in my form and show it only.
Do you have nay suggestion ?
Thanks!
modified 11-Mar-13 3:32am.
|
|
|
|
|
Sorry, no other ideas. A commercial library or learning the office powerpoint binary format (probably not worthwhile as it's pretty much been replaced by the open and easier for coding pptx format) and rolling your own may be all that's left.
|
|
|
|