|
I need to allow an administrator to change login passwords for my application but am having problems with the syntax for the UPDATE statement. Specifically, I want to use Data Commands rather than working through a data set to make the updates because I will only need to do two operations with the MS Access database-verifying the old password/user id combo and updating the password to a new one. It seems to me that the UPDATE statement requires paramaters, but I am unsure of the syntax. Any help would be appreciated. Thanks.
|
|
|
|
|
The syntax for the SQL command you will need is easy:
UPDATE [table] SET [field]=[value],[field]=value,.. WHERE [filterexpression]
Replace the [...] for the actual names and values.
For the rest you need a simple piece of code like this:
OleDbConnection connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=mydb.mdb");
OleDbCommand cmd = new OleDbCommand(query,connection);
try {
connection.Open();
cmd.ExecuteNonQuery();
}
catch {
}
finally {
connection.Close();
}
Good luck.
WM.
What about weapons of mass-construction?
|
|
|
|
|
If you were working thru a dataset you would not have to know any SQL statements after populating the dataset.
Using the dataset is simple
1> create and fill the dataset with dataAdapter.
2> create new SQL command builder associated with dataAdapter
3> get new row from DataTable edit row(record) - (user/password)
4> simply update the database thru the adapter
Besides from initially populating the dataset no SQL involved
|
|
|
|
|
Hi, can someone help me...??
I have data in a Access-database, i add the data to a arrayList and show the data from the arrayList in a dataGridView. All that works perfect.
Now i want to add data to the arrayList (and then to the Access-database).
I want to use the dataGridView, so i clear it by: dataGridView1.Rows.Clear();
Then i would like to add data to the empty rows and press a Save-button to save the data.
I have tried something like this:
foreach (DataGridViewRow gridRow in dataGridView1.Rows)
{
KampListe.Add(new Kamp(Convert.ToString(gridRow["kampnr"]), Convert.ToString(gridRow["Idrætsgren"]), Convert.ToString(gridRow["Turnering"]), Convert.ToString(gridRow["Dato og Tid"])));
}
but it will not work...., what is the problem...???
Helge
|
|
|
|
|
ArrayList listing = new ArrayList();
int i;
for (i=0;i<=dataGridView1.Rows.Count -1;i++)
{
listing.Add(i.ToString());
}
check this link too
http://blog.kevinsmet.be/PermaLink,guid,22de02a3-2fc8-482a-99f9-c5f293a41c79.aspx
|
|
|
|
|
Hi again, i can still not solve my problem...
In my dataGridView1 i have 9 coloumns, how do i get each cells value in all 9 coloumns...???
Helge
|
|
|
|
|
ArrayList listing = new ArrayList();
int i;
for ( i=0;i<=this.dataSet11.Tables[0].Rows.Count - 1;i++)
{
listing.Add(dataSet11.Tables[0].Rows[i]["column1"].ToString()); listing.Add(dataSet11.Tables[0].Rows[i]["column2"].ToString()); listing.Add(dataSet11.Tables[0].Rows[i]["column3"].ToString()); listing.Add(dataSet11.Tables[0].Rows[i]["column4"].ToString());
listing.Add(dataSet11.Tables[0].Rows[i]["column5"].ToString());
listing.Add(dataSet11.Tables[0].Rows[i]["column6"].ToString());
listing.Add(dataSet11.Tables[0].Rows[i]["column7"].ToString());
listing.Add(dataSet11.Tables[0].Rows[i]["column8"].ToString());
listing.Add(dataSet11.Tables[0].Rows[i]["column9"].ToString());
}
i have done this in windows application, but i havtn free time to write in web app but i hope helps as clue...
|
|
|
|
|
Hello.
How can I fire up a button event without pressing the button?
Thank you
|
|
|
|
|
private void button1_Click(object sender, System.EventArgs e)
{
//Do some code
}
private void timer1_Tick(object sender, System.EventArgs e)
{
this.button1_Click(this,e);
}
ur code which is written in click event of button should execute in everey seconds,minutes,hours,... by timer whithout clicking button
but first set property to true of timer in design view or in form1_load
example :
timer1.enabled=true;
hope helps
|
|
|
|
|
You can event try calling button1.PerformClick() method.
Thanks,
VPMahank.
|
|
|
|
|
Something like
<br />
private byte[] getImageBytes()<br />
{<br />
byte[] buffer = null;<br />
FileStream templateStream = File.Open(@"C:\MyImage.gif", FileMode.Open);<br />
buffer = new byte[templateStream.Length];<br />
templateStream.Write(buffer, 0, (int)templateStream.Length);<br />
templateStream = null;<br />
return buffer;<br />
}<br />
The code runs but I only get a buffer containing zero's
Thanks
Thomas
|
|
|
|
|
Try flushing the file stream (and also, you MUST dispose the FileStream as well). Setting it to null is pointless; you only need to do that in Java.
private byte[] getImageBytes()
{
byte[] buffer = new byte[templateStream.Length];
using(FileStream templateStream = File.Open(@"C:\MyImage.gif", FileMode.Open))
{
templateStream.Write(buffer, 0, (int)templateStream.Length);
templateStream.Flush();
}
return buffer;
}
Please note that if you're using the latest version of the .NET framework, you can use the File.ReadAllBytes method, which is more efficient and requires only a single line of code:
private byte[] getImageBytes()
{
return File.ReadAllBytes(@"c:\MyImage.gif");
}
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Bought a House!
Judah Himango
|
|
|
|
|
|
|
Judah Himango wrote: Setting it to null is pointless; you only need to do that in Java.
OT, but I thought the Java GC also worked the same way as .NET, it's mark and sweep and doesn't require references to be set to null?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
In Java, this is a common way of letting the GC know you're done with it. With .NET, it isn't needed. I believe the Java GC would eventually clean up objects even if they weren't set to null, but doing so would supposedly help it along.
|
|
|
|
|
Thanks, just one thing that was horrably wrong, it should be
templateStream.Read(buffer, 0, (int)templateStream.Length);
by using the templateStream.Write(...) it zero's out the image
so it should be
<br />
private byte[] getImageBytes()<br />
{<br />
byte[] buffer = new byte[templateStream.Length];<br />
using(FileStream templateStream = File.Open(@"C:\MyImage.gif", FileMode.Open,FileAccess.Read)) <br />
{<br />
templateStream.Read(buffer, 0, (int)templateStream.Length);<br />
templateStream.Flush();<br />
}<br />
return buffer;<br />
}<br />
<br />
|
|
|
|
|
thomasa wrote: templateStream.Write(buffer, 0, (int)templateStream.Length);
You should be reading from the file, not writing. Anyways your file is blank now, so you will have to create the image, else you will carry on getting zero's.
xacc.ide-0.1.1 released! :) Download and screenshots
|
|
|
|
|
Like leppie said:
FileStream templateStream = File.Open(@"C:\MyImage.gif", FileMode.Open);
buffer = new byte[templateStream.Length];
templateStream.Write(buffer, 0, (int)templateStream.Length);
Shouldn't that be READ??? In either case, the file has already been destroyed when you ran this code for the first time. You'll have to correct the code to Read, then replace the .GIF file with a known good copy.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi.....
Im workin on Icon class where im gettin this exception at the declarartion of the icon obj
private Icon myIcon= new Icon(typeof(Form1)).Assembly.GetManifestResourceStream("winapptry.app.ico" ));
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
with additional info as
Additional information: Could not find file "..\Visual Studio Projects\winapptry\bin\Debug\winapptry.app.ico".
just dunno how to sort tht out
sathy
-- modified at 8:15 Wednesday 28th December, 2005
|
|
|
|
|
First of all you have forgotten a "(" so your code won't even compile.
Check the following:
1. You have a file named "app.ico" in the same project as Form1 (and not in a subfolder).
2. This file is a valid icon.
3. You have set its build action to "Embedded Resource".
4. The root namespace of your project is named "winapptry".
|
|
|
|
|
Thanks a lot Robert
"(" this is bcoz i edited the code here
its the third point is wat i missed out.....
GREAT!!!!!!!
sathy
|
|
|
|
|
Hi ..
i have a few textBoxes that are bounded to a tableview...
but whenever i change my ROWFILTER at the tableview , the Bounded textboxes remain the same...
this is the databind code:
UpdateCoptxtMa.DataBindings.Add("Text",source[0],"Ma");
UpdateCoptxtFirstName.DataBindings.Add ("Text",source[0],"FirstName");
UpdateCoptxtLastNAme.DataBindings.Add ("Text",source[0],"LastName");
UpdateCoptxtAddress.DataBindings.Add ("Text",source[0],"Address");
cboYehida.DataBindings.Add("Text",source[0],"Yehida");
UpdateCoptxtStatus.DataBindings.Add("Text",source[0],"Status");
UpdateCoptxtHomePhone.DataBindings.Add("Text",source[0],"HomePhone");
UpdateCoptxtCellPhone.DataBindings.Add("Text",source[0],"CellPhone");
And the RowFilter code:
source.RowFilter="(LastName + ' ' + FirstName)='"+SelectedCopName +"'";
Thanx! Yosi
|
|
|
|
|
.
.
.
.
.
source.RowFilter="(LastName + ' ' + FirstName)='"+SelectedCopName +"'";
urdataview.RowStateFilter = DataViewRowState.ModifiedCurrent;
i am not so sure but hope helps???
|
|
|
|
|
nope.. when i try using it it throws an exception .
"index 0 is not negative and below total rows cund"
whenever he tries to bind it for example: UpdateCoptxtMa.DataBindings.Add("Text",source[0],"Ma");
i'm lookin for some way , to refresh the textBoxes, ReBInd them i dunno , a way to make them realize that the datasource has changed...!
thanks anyway..
Any other suggestions? please?
|
|
|
|