|
Copying a file to a remote computer without having the remote computer authenticate and accept the transfer would be a perfect vector for a virus or trojan. Fortunately, you can't do this, and if there were a way, no one here would help you because of the patently malicious intent of such an operation.
|
|
|
|
|
Hello everyone,
I am currently working on a DVD Playback Windows Application using C# and would like to add the option of grabbing image samples. My research led me to IsampleGrabber interface.
I was wondering if anyone knows a detialed step by step tutorial on ISampleGrabber interface using C# programming? Your help is greatly appriciated.
Thank you very much and have a great weekend.
Khoramdin
|
|
|
|
|
|
|
I'm using the following code to insert/update records to an Access database using a DataSet. (Don't worry too much about the 'EdiDatastore' class - I just use it to encapsulate some DB functionality - should be self explanatory).
Note that the DriverID is an AutoNumber field in the Access DB.
<br />
myDriverDB = new EdiDatastore();<br />
myDriverDB.open();<br />
myDriverDB.sqlCommand("SELECT DriverID, DriverName, DriverVersion, DriverDLL, DriverEnabled FROM Drivers");<br />
myDriverDB.makeDataAdapter();<br />
<br />
myDriverDB.dataAdapter.InsertCommand = myDriverDB.conn.CreateCommand();<br />
myDriverDB.dataAdapter.InsertCommand.CommandText = "INSERT INTO Drivers " +<br />
"(DriverName, DriverVersion, DriverDLL, DriverEnabled) " +<br />
"VALUES (?,?,?,?)";<br />
myDriverDB.dataAdapter.InsertCommand.Parameters.Add("DriverName", OleDbType.VarWChar, 255, "DriverName");<br />
myDriverDB.dataAdapter.InsertCommand.Parameters.Add("DriverVersion", OleDbType.VarWChar, 100, "DriverVersion");<br />
myDriverDB.dataAdapter.InsertCommand.Parameters.Add("DriverDLL", OleDbType.VarWChar, 100, "DriverDLL");<br />
myDriverDB.dataAdapter.InsertCommand.Parameters.Add("DriverEnabled", OleDbType.Boolean, 10, "DriverEnabled");<br />
<br />
myDriverDB.dataAdapter.UpdateCommand = myDriverDB.conn.CreateCommand();<br />
myDriverDB.dataAdapter.UpdateCommand.CommandText = "UPDATE Drivers " +<br />
"SET DriverName=?, DriverVersion=?, DriverDLL=?, DriverEnabled=? " +<br />
"WHERE DriverID=?";<br />
myDriverDB.dataAdapter.UpdateCommand.Parameters.Add("DriverName", OleDbType.VarWChar, 255, "DriverName");<br />
myDriverDB.dataAdapter.UpdateCommand.Parameters.Add("DriverVersion", OleDbType.VarWChar, 100, "DriverVersion");<br />
myDriverDB.dataAdapter.UpdateCommand.Parameters.Add("DriverDLL", OleDbType.VarWChar, 100, "DriverDLL");<br />
myDriverDB.dataAdapter.UpdateCommand.Parameters.Add("DriverEnabled", OleDbType.Boolean, 10, "DriverEnabled");<br />
myDriverDB.dataAdapter.UpdateCommand.Parameters.Add("DriverID", OleDbType.Boolean, 10, "DriverID");<br />
<br />
DataSet myDriverDS = myDriverDB.getDataSet("MyTable");<br />
<br />
DataRow driverDR = myDriverDS.Tables[0].NewRow();<br />
driverDR["DriverName"] = "Test";<br />
driverDR["DriverVersion"] = "0.0.0";<br />
driverDR["DriverDLL"] = "test.dll";<br />
driverDR["DriverEnabled"] = true;<br />
<br />
myDriverDS.AcceptChanges();<br />
myDriverDS.Tables[0].AcceptChanges();<br />
<br />
DataRow driverDR2 = myDriverDS.Tables[0].NewRow();<br />
driverDR2["DriverName"] = "Test";<br />
driverDR2["DriverVersion"] = "0.0.0";<br />
driverDR2["DriverDLL"] = "test.dll";<br />
driverDR2["DriverEnabled"] = true;<br />
<br />
myDriverDS.Tables[0].LoadDataRow(driverDR.ItemArray, true);<br />
myDriverDS.Tables[0].LoadDataRow(driverDR2.ItemArray, true);<br />
myDriverDS.Tables[0].AcceptChanges();<br />
myDriverDS.AcceptChanges();<br />
<br />
myDriverDB.dataAdapter.Update(myDriverDS, "MyTable");<br />
Application.DoEvents();<br />
<br />
myDriverDB.close();<br />
The problem is that the DataTable.LoadDataRow method doesn't actually execute any database commands (I have tested this by creating intentional syntax errors in the SQL insert and update commands - no exceptions are thrown). The DataSet itself shows the inserted values correctly.
I have tried removing the DriverID column from the DataSet, but that doesn't make a difference. Can anyone tell me why this code would not update the new rows in the dataset to the database?
|
|
|
|
|
Try this article
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Ok.. Took me a minute to figure out what you where referring to but I figured it out. Didn't know about the DataAdapter.Update(DataSet.GetChanges(),Table) syntax.
Thanks.
|
|
|
|
|
I have a small code like this
private DataTable getData (string sql, sqlConnection con){
{
DataTable tempdt = new DataTable();
try {
sqlDataTableAdapter adap = new sqlDataTableAdapter(sql,con);
adapt.Fill(tempdt);
}
return tempdt;
}
private bool saveData(string sql, sqlConnection con, DataTable dt)
{
sqlDataTableAdapter adap = new sqlDataTableAdapter(sql,con);
sqlCommandBuilder buider = new sqlCommandBuilder (adap);
adap.FillScheme(dt,SchemeType.Sourced);
adap.Fill(dt);
bool bResult = (adap.Update(dt)) == 1? true:false;
return bResult;
}
private Form_Load ()
{
datagrid1.Datasource = getData(("SELECT DriverID, DriverName, DriverVersion, DriverDLL, DriverEnabled FROM Drivers", connection1);
}
private btnRefresh_Click ( .... )
{
string sql = ("SELECT DriverID, DriverName, DriverVersion, DriverDLL, DriverEnabled FROM Drivers where DriverID = 0");
DataTable dt = (DataTable)datagrid1.Datasource ;
if (saveData(sql,con,dt) == true )
{
MessageBox.Show ("Successful");
}
}
Hope my help !
|
|
|
|
|
In C++, many times I use global variables to hold values that I need in more than 1 class. As an example, during initialization process I (Programmatically) find the path to current executable module and store it in a global string variable. Or some of the options of the application that has a wide range of use, will be loaded (at RUN TIME) and used in several classes later.
In C#, however, I've read that there is not any global variable because it shows a poor design, instead we shall use app.config file. Is it possible to add/retrieve a variable to this file at RUN TIME? if not what sort of design pattern should I use for problems like I mentioned above?
Thanks a lot in advanced.
//This is not a signature
while (I'm_alive) {
cout<<"I Love Programming";
}
|
|
|
|
|
A global variable can be accessed by any method and a local variable can only be accessed by the method it is declared in. When a variable is declared outside of all methods it becomes global. Here is an example that shows that a local variable can only be accessed in its method and that a global variable can be accessed from any method.
using System;<br />
<br />
class methods<br />
{<br />
static int MyGlobalVariable;<br />
<br />
static void ChangeGlobalValue()<br />
{<br />
int MyLocalVariable;<br />
MyLocalVariable = 4;<br />
MyGlobalVariable = 5;<br />
}<br />
<br />
public static void Main()<br />
{<br />
MyGlobalVariable = 7;<br />
ChangeGlobalValue();<br />
}<br />
} <br />
<br />
Regards,
Satips.
|
|
|
|
|
What is this!
I understand what's global, and what's local! I'm seeking a way to make scope of a global variable as large as my application, not only within a class.
Please read questions more carefully. I provided example of what I want.
I appreciate your will to help me and thank you very much, but the answer shows me that you just want to answer, regardless of the question. that made me angry in first place.
Sorry!, Within your answer (Code ) relies an answer to my question. Just the text, you know, made me a bit angry. Thanks.
-- modified at 4:28 Sunday 8th April, 2007
//This is not a signature
while (I'm_alive) {
cout<<"I Love Programming";
}
|
|
|
|
|
public class A
{
public static int globalVar;
}
private class B
{
A.globalVar = 1;
}
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Wow! Nice idea!
This is not as easy as a C++ global variable(I still need to identify owner: MyForm1.A.globalVar ), but this is a clever solution to the lack of global variables. Got my 5! Thanks.
A suggestion, make class A sealed.
//This is not a signature
while (I'm_alive) {
cout<<"I Love Programming";
}
|
|
|
|
|
Hamed Mosavi wrote: This is not as easy as a C++ global variable
It's a bit more verbous than using global variables, but verbosity is not bad in itself.
The advantages over global variables is that it's easy to locate the variable as the code says exactly where to look, and that there is no risk of name conflicts with other modules that also uses global variables.
Hamed Mosavi wrote: I still need to identify owner: MyForm1.A.globalVar
Put the class outside the form (perhaps in a class file by itself), then you only have to specify the name of the class: A.globalvar .
Hamed Mosavi wrote: A suggestion, make class A sealed.
Even better, make the class static. Then you can't put non-static members in it by mistake, and it's automatically sealed. Also it's obvious how the class is supposed to be used.
---
single minded; short sighted; long gone;
|
|
|
|
|
What I have done is created an AppSettings class which has many public properties - example:
sealed class AppSettings
{
static string appDir;
public static string AppDirectory
{
get
{
if (appDir != null)
return appDir;
appDir = (code to get app dir);
return appDir;
}
}
}
And then I can use it from anywhere in the application.
Mike
|
|
|
|
|
Mike_V wrote: What I have done is created an AppSettings class which has many public properties
I was thinking just about the same technic;)
//This is not a signature
while (I'm_alive) {
cout<<"I Love Programming";
}
|
|
|
|
|
Mike_V wrote: created an AppSettings class
You mean like what is already available by using app.config?
only two letters away from being an asset
|
|
|
|
|
Not quite... otherwise I would have used app.config
|
|
|
|
|
Hamed Mosavi wrote: In C#, however, I've read that there is not any global variable because it shows a poor design, instead we shall use app.config file.
Correct.
Hamed Mosavi wrote: Is it possible to add/retrieve a variable to this file at RUN TIME?
If this is needed in your design then you may be better off considering a datastore, such as SQL Server Express or Compact Edition, both are free, lightweight and easily coded against. It would also allow for a easier upgrade path from your application, or to a full SQL Server implementation if necessary.
only two letters away from being an asset
|
|
|
|
|
Hi,
Is it possible to send a certificate chain to the client from a server SslStream during handshakes? I need to be able to do this, but SslStream doesnt' seem to support it...
however, during client validation, the calllback DOES have a X509Chain argument, is the chain support only one-way?
Thanks
|
|
|
|
|
Im coding a virtual hair styling and makeover tool. Can any buddy know any link or idea abt virtual makeover.... Any link for the help.......
actually when I apply makeover it should blend the applied color on the skin. How can I get the blended effect?? Wht function I should use on the pixel previos color and the new color to be applied........ ANY Idea?????
|
|
|
|
|
I have a form with a complex graph drawn on it. As the graph does not fit the available area on the form, scrollbars need to be used for navigating around the graph.
I am thinking of an "atlas" or "navigation" control, something similar to the one we see in Google maps, when we hover the cursor over the small navigation pane, the cursor changes to a highlighted square, clicking on the pane and moving the cursor around pans the map in the main view.
If anyone is aware of such a control, it will be great if you can please share the link.
Thanks for your attention.
indy
|
|
|
|
|
Hello everyone,
I just try to add panels in my windows form and then add some textbox to these newly added panels. Unfortunately, while the panels seems ok the textboxes do not appear!
I try the BringToFront() method but this doesn't work too. What can the problem be?
Thanks.
.:: Something is Wrong ::.
|
|
|
|
|
Seeing some code would help us to help you...
|
|
|
|
|
I add the panels dynamically with :
<br />
Panel p = new Panel();<br />
p.Location = new Point(3, panel1.Controls[panel1.Controls.Count - 1].Location.Y + 28);<br />
p.Size = new Size(262, 26);<br />
p.BackColor = Color.Blue;<br />
panel1.Controls.Add(p);<br />
The panels are added to panel1 with no problem. Everything is ok. Then I try to add 3 textboxes to the last panel.
<br />
.....<br />
for (int i = 0; i < 3; i++)<br />
{<br />
TextBox t = new TextBox();<br />
addTEv(i, t);<br />
}<br />
<br />
<br />
<br />
}<br />
<br />
private void addTEv(int i, TextBox t)<br />
{<br />
if (i == 0)<br />
t.Location = new Point(3, panel1.Controls[panel1.Controls.Count - 1].Location.Y);<br />
else if (i == 1)<br />
t.Location = new Point(93, panel1.Controls[panel1.Controls.Count - 1].Location.Y);<br />
else<br />
t.Location = new Point(183, panel1.Controls[panel1.Controls.Count - 1].Location.Y);<br />
<br />
t.Size = new Size(75, 20);<br />
t.BorderStyle = BorderStyle.FixedSingle;<br />
t.BackColor = Color.White; <br />
panel1.Controls[panel1.Controls.Count - 1].Controls.Add(t);<br />
}<br />
Thanks.
.:: Something is Wrong ::.
|
|
|
|
|