|
I am writing an application that monitors users' bandwidth and disables their network connection if they have downloaded/uploaded to much data. For users with a DHCP IP address this is simple but I am having troubles with people with Static IPs. The best idea I could come up with is to just disabled the network card, but I don't know how to.
Can anyone give me some ideas?
Thanks,
Eric Sanders
Purdue University
|
|
|
|
|
Hi all,
I'm missing a simple disable property bit which prohibits the change of data in all input controls.
control.enable = false;
Is there an other way than to jump to an unvisible dummy-control when enter/change/cut&paste... is triggering ?
It would be useful to make an expansion of the form/controls base class from which I can inherit all input controls.
Does someone have an idea how to do that ?
Thanks for your ideas !!
Regards
Frank
|
|
|
|
|
You're right. It's a missing feature what would be nice. Some controls have a ReadOnly property which you could use. Making a base class will not be so easy. You could define an interface and try to inherit from every control you need and implementing this interface. But you will nevertheless have to implement the ReadOnly behaviour yourself in most controls.
|
|
|
|
|
Hi. I’ve managed to call a unmanaged c++ dll function into a C# project using the DllImport attribute. Now I like to Import a hole class that my old dll exposes. Is that possible and how do I do that?
_____________________________
...and justice for all
APe
|
|
|
|
|
Heya!
I'm using databinding to an object. I'm binding a txt box to the object's Name property. The Name property is a string of length no longer than 10 chars. In the Name property's set accessor method, I check if the string value's length > 10. If it is I throw a FieldLengthException(my own).
The problem:
In the UI I want to catch this exception but I'm not sure where this exception can be caught (or for that matter where to put the try clause)
Eg.
<br />
public class Person<br />
{ <br />
private string _Name = "";<br />
<br />
public string Name<br />
{<br />
get { return _Name; }<br />
set <br />
{<br />
if (Name.Length > 10)<br />
throw new FieldLengthException("Field restricted to 10 characters");<br />
else<br />
_Name = value;<br />
}<br />
}<br />
}<br />
<br />
Person p = new Person();<br />
<br />
Binding bName= new Binding("Text", p, "Name");<br />
tbName.DataBindings.Add(bName);
<br />
|
|
|
|
|
|
Sorry please help me out
I got this error when doing SQL INSERT.
"Object reference not set to an instance of an object."
This was my coding:
string connStr = ConfigurationSettings.AppSettings["ConnectionString"];
string desc = txtMailing.Text;
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\testing_K_\db1.mdb");
OleDbCommand cmd = new OleDbCommand();
OleDbDataAdapter oleDbDataAdapter1 = new OleDbDataAdapter(cmd);
oleDbDataAdapter1.InsertCommand.CommandText =
"INSERT INTO Mailing (MailingField)" +
"VALUES ('"+ desc +"')";
//open the bridge between the application and the datasource
con.Open();
oleDbDataAdapter1.InsertCommand.Connection = con;
//execute the qurey
oleDbDataAdapter1.InsertCommand.ExecuteNonQuery();
//close the connection
con.Close();
The underlined sentence is the error. Please give me tips or advice to solve this.
Thanks
fire85.
|
|
|
|
|
Hi.
To make an update you do not need the data adapter.
Write like this and you will be happy:
<br />
SqlConnection con = ...<br />
try {<br />
using (SqlCommand cmd = new SqlCommand("INSERT ...", con)) {<br />
cmd.ExecuteNonQuery();<br />
}<br />
catch (SqlException ex) {<br />
}<br />
if (con != null) {<br />
con.Dispose();<br />
con = null;<br />
}<br />
By the way, using is nice, it runs Dispose() on your command-object automatically.
/M
|
|
|
|
|
Yeah Thanks alot
It works
fire85.
|
|
|
|
|
The SqlCommand parameter in the SqlDataAdapter constructor is for the SelectCommand , not the InsertCommand . But the other response is correct, you don't need the SqlDataAdapter . The SqlCommand.ExecuteNonQuery call is enough.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Sorry i am a newb to programming, cant get the meaning of what you trying to say.
Is there any article or book that clearly explain about database linking??
Please introduce to me Thanks
fire85.
|
|
|
|
|
You need an SqlCommand object to represent execute any SQL statement on the database. The SqlDataAdapter is only a bridge that connects the data obtained from the database by executing a SELECT command, to a DataSet or DataTable (which can hold data on which you can work, without being connected to the database.)
The SqlDataAdapter can also contain other commands (specifically, one INSERT , UPDATE and DELETE ) that will be used when you ask it (the data adapter) to save the changes you've made to the offline data (DataTable or DataSet ) to the actual database.
So, it works like this:
1. You create a SqlCommand object representing your SELECT statement (it can be a stored procedure wrapping a SELECT statement.)
2. You create a new SqlDataAdapter object and pass it the SELECT statement.
3. You create an empty DataTable (or DataSet )
4. When you call myDataAdapter.Fill(myDataTable) , the SELECT statement is executed in the database, and all the returned records are stored into the myDataTable object.
5. You start working with the data in the myDataTable object. You can add, modify or delete records offline, and your changes will not be saved in the real database. At this point you are not connected to the database.
When you want to update the database with the changes you made to myDataTable , you follow these steps:
1. Create SqlCommand objects for the INSERT , UPDATE and DELETE queries.
2. Assign those command objects to the InsertCommand , UpdateCommand , and DeleteCommand properties of SqlDataAdapter object (myDataAdapter here).
3. Call myDataAdapter.Update(myDataTable) .
4. The data adapter will look at each record in myDataTable and see what kind (if any) of modification it has had, and execute the appropiate command (INSERT if the row was added, UPDATE if it was modified, or DELETE if it was removed.)
So, to your question. First see this[^] topic in MSDN. Can you see that the constructor's argument is named selectCommand ?
When you pass your SqlCommand (which does represent an INSERT query) to the constructor, it's taken as the SELECT command. So, when you try to access it through the InsertCommand property, it naturally is null, since you have not initialized it to something. A quick fix would be to set the InsertCommand to your cmd object before trying to set its CommandText:
<code>OleDbDataAdapter oleDbDataAdapter1 = new OleDbDataAdapter(cmd);
oldeDbDataAdapter1.InsertCommand = cmd;
oleDbDataAdapter1.InsertCommand.CommandText =
"INSERT INTO Mailing (MailingField)" +
"VALUES ('"+ desc +"')"; But as you saw from the above description of data adapters, since you are executing a query and you don't get any results back, a DataAdapter is overkill (actually you are not using it, you just use it to hold a command object which you then execute directly.) So, get rid of the data adapter:
string connStr = ConfigurationSettings.AppSettings["ConnectionString"];
string desc = txtMailing.Text;
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\testing_K_\db1.mdb");
OleDbCommand cmd = new OleDbCommand();
cmd.CommandText = "INSERT INTO Mailing (MailingField) VALUES (?)";
con.Open();
cmd.Parameters.Add("param1", desc);
cmd.ExecuteNonQuery();
con.Close(); As you can see, there's no OleDbDataAdapter (I just noticed you are using Access and not SQL Server, but all the above description equally applies.)
Note the bold text in the code above. Your code as you had it contains a serious security vulnerability (it's vulnerable to SQL injection attacks, see this article). The code I provided you contains paramters, which, for one thing prevent this[^] type of attacks, but also avoid problems if somehow there's a single quote (' ) in the desc variable.
I hope this helps!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Ya is much more clearer to me now.
Thanks alot LuisR, you have been a great help
Thanks
fire85.
|
|
|
|
|
fire85 wrote:
Ya is much more clearer to me now.
Thanks alot LuisR, you have been a great help
You're very welcome! I'm glad I could help!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
I have a set of ActiveX controls, which provide access to underlying document and its structure.
The main document has an Items collection, which holds information on all objects defined within this document.
I am trying to build a convertor for the documents and therefore need to enumerate all items within this collection.
The problem is that Items collection holds different types (classes) of data, e.g. Line, Rectangle, Ellipse, String, and the function TypeName in VB6 would return these names. In C# the GetType() method returns always the name of abstract class. The function TypeName in VB.Net provides the same result as C#.
Does anybody know how to get same result as in VB6.0?
Unfortunatelly I am not able to provide you with this ActiveX control, because they're part of commercial software
|
|
|
|
|
Guys,
I have to build a web application to make a phone call from a call center and record the phone call. Then it must be possible to later recall the conversation with it's corresponding stored call entry which was inserted into a DB table.
I looked at the MS TAPI and it seems like the way to go. Can any body point me in any sort of direction on where to start?
Thanks in advance!
|
|
|
|
|
TAPI and C# aren't the easiest of bedfellows.
I prefer to write COM wrapper around C++/TAPI code and use COM/Interop
However there is a useful C# wrapper around TAPI 2, here[^]
Michael
CP Blog [^] Development Blog [^]
|
|
|
|
|
Hi,
I have an application with links to word files.
With the link, I display the lastupdatedate, but I need also the LastUpdateUser.
Is it possible to find it?
Thanks
|
|
|
|
|
have you tried using the DSOFile.dll. Its ideal for handling office documents. See this link :
http://support.microsoft.com/kb/q224351/
edit:
You can also try using the FileInfo class in .NET as well.
|
|
|
|
|
Suppose I want an application which takes a source file and outputs its data members and functions.
Supposed to develop into a kind of class view explorer.
Regarding parsing the source file ....
should i go for using regular expressions rules for this parsing or
should i go for a language representation in context free grammer[CFG] and use the CFG rules for parsing
or is there any other possible ideas for source file parsing
awaiting advice
fordge
|
|
|
|
|
|
how to locate an accurate position in the vectorgraph in C#?
for example,when i move the cursor into the vectorgraph,and do the click
on one position(point),how can i get its accurate position?
I am from Shanghai China,please forgive my poor English!
wish u good luck
shi fangting
Where there is a will,there is a way!
|
|
|
|
|
i used .NET remoting in my app, but i couldn't release ref object at server-side.
How do release MarshalByrefobj ????
thanks
bachkhoa
|
|
|
|
|
|
Can any one help me as to give me the name of the method call in .Net
that sees if a file contains a specific text that is not System.IO.Directory.GetFiles I know that such a method exist because I have used it 3 years ago but cannot remember the name of the method Ps also
not by using the envDTE find method that really suchs and is slow
|
|
|
|