|
See the 3rd reply on this[^] page.
/ravi
|
|
|
|
|
thanks , It's a good Lesson !
|
|
|
|
|
I created a RelayCommand:
public class RelayCommand<T> : ICommand
{
readonly Action<T> _execute = null;
readonly Predicate<T> _canExecute = null;
public RelayCommand(Action<T> execute)
: this(execute, null)
{
}
public RelayCommand(Action<T> execute, Predicate<T> canExecute)
{
if (execute == null)
throw new ArgumentNullException("execute");
_execute = execute;
_canExecute = canExecute;
}
public event EventHandler CanExecuteChanged;
public bool CanExecute(object parameter)
{
return _canExecute == null ? true : _canExecute((T)parameter);
}
public void Execute(object parameter)
{
_execute((T)parameter);
}
}
I have 2 questions:
I'm trying to have the command pass an enum to the action method:
private ICommand _PerformanceCommand;
public ICommand PerformanceCommand
{
get
{
if (_PerformanceCommand == null)
{
_PerformanceCommand = new RelayCommand<ViewCategory>(p => buttonClicked(ViewCategory.Peformance));
}
return _PerformanceCommand;
}
}
private ICommand _SettingsCommand;
public ICommand SettingsCommand
{
get
{
if (_SettingsCommand == null)
{
_SettingsCommand = new RelayCommand<ViewCategory>(p => buttonClicked(ViewCategory.Settings));
}
return _SettingsCommand;
}
}
and then
private void buttonClicked(ViewCategory args)
{
}
The code throws an exception in the command class on
public void Execute(object parameter)
{
_execute((T)parameter);
}
1) Not sure why it's null if the command is passing an enum value.
2) How can I refactor the relay command so that it can take a type, or not take a type. In other words
public class RelayCommand : ICommand
public class RelayCommand<T> : ICommand
Would I need to separate classes for this?
Thanks
Everything makes sense in someone's mind
|
|
|
|
|
search item from listview with id for exemple
in C#
|
|
|
|
|
Yeah, you're going to have to explain a bit more about what you're doing and why in order for us to help you. We have no idea what you're trying to do.
|
|
|
|
|
Just search through the underlying datasource using LINQ.
|
|
|
|
|
Hi All ,
how can I streaming video using c# ?? what library do I need to do this ?
Thank you
|
|
|
|
|
DirectShow.Net[^] can help you capture and stream video.
There are a number of other third party tools available.
|
|
|
|
|
could you suggest to me a library to do that,. Iam a new in C# .
Thank you
|
|
|
|
|
Hi, I have a problem with my homework assignment.
I am able to access the database and insert new customer but it doesn't work when i try to update any record.
if anyone can tell me what is wrong with my code.
thank you so much
this is all my code
protected void btnUpdate_Click(object sender, EventArgs e)
{
<big>
if (Request.QueryString["id"] != null)
{
SqlConnection Conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyLocal"].ConnectionString);
Conn.Open();
string sql = "UPDATE [Customer] SET [FirstName] = @FirstName, [LastName] = @LastName, [Email] = @Email, [Password] = @Password, [Address1] = @Address1, [Address2] = @Address2, [City] = @City, [State] = @State, [zip] = @zip, [Phone] = @Phone, [Fax] = @Fax WHERE CustomerID=@CustomerID";
SqlCommand cmd = new SqlCommand(sql, Conn);
cmd.Parameters.AddWithValue("@CustomerID", CustomerID);
cmd.Parameters.AddWithValue("@FirstName", txtFirstName.Text);
cmd.Parameters.AddWithValue("@LastName", txtLastName.Text);
cmd.Parameters.AddWithValue("@Email", txtEmailA.Text);
cmd.Parameters.AddWithValue("@Password", txtPasswordA.Text);
cmd.Parameters.AddWithValue("@Address1", txtAddress1.Text);
cmd.Parameters.AddWithValue("@Address2", txtAddress2.Text);
cmd.Parameters.AddWithValue("@City", txtCity.Text);
cmd.Parameters.AddWithValue("@State", txtState.Text);
cmd.Parameters.AddWithValue("@Zip", txtZip.Text);
cmd.Parameters.AddWithValue("@Phone", txtPhone.Text);
cmd.Parameters.AddWithValue("@Fax", txtFax.Text);
cmd.ExecuteNonQuery();
Conn.Close();
Response.Redirect("Customers.aspx");
}
modified 9-Mar-12 12:04pm.
|
|
|
|
|
It would help you cut this down to relevant code to your problem.
What line is the error ocurring?
What is the actual error that you are getting?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
<b<big>i want to create notification in desktop application how can i create it for example when i click in button show me the notification???>
modified 9-Mar-12 7:57am.
|
|
|
|
|
If all you want is an indication that the button has been pressed, then:
MessageBox.Show("Please do not press this button again"); Will do the job...
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Please read the topic how you post a question in this forum, before actually doing so.
You'll get better responses.
V.
|
|
|
|
|
And please do not cross post.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
hi there again guys as usual i have a problem which i would like some help with
i have a website with a textbox and a click button
also it has 2 check boxes
my plan is to enter a weblink into the textbox untick 2 check boxes and click submit button all in c# so i want my app to load page and enter details programatically , enter weblink , untick boxes , press submit button and allow page to load in c# webbrowser control with _self
please help guys thanks
the source code for the submit buttin is
input type="image" src="data:image/gif;base64,R0lGODdhHgAOAHcAACwAAAAAHgAOAIcAAACAAAAAgACAgAAAAICAAIAAgIDAwMDA3MCmyvBHRkNHRmJmRkNmRmJmZUNHRoJHZaFHhMBmo+CERkOjZUPChEPChGLgo2KEhIKEwf+j4P//wYL/4KHC/+DC/////8Dg/////+D///9wAtIAAAAAAAAAAAAAAAAFAAJwAtIAAAAAAAAXC7AAAAAAAAwAAAAAAAMqCuAWbFgWbXAT7XAXDJgAAAAS7xQAAAAS8Egy4O34Lrj///42L+c2LoIAAAAaxTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAS8BhHNEwAAAAAAAAAAAAAAAAS8NwS8NwAAoES8Nw6ajQAAoES8CBBzNE4CrRC1IFC1Ik6ajQ4CtRHMMcS8EhHMN5HMOYS8PRHMPAAAAAS8NwAAoEAAAA6ajQS8GBCY+4AAoEAAAEAAA8AAAAS8IzIxOcUBNoAAoEAAAEAAA8AAoG6q80AAAAS8NwAAoES8JwS8LjNmNgAAAcS8dwAAAcAAAA6ajRIxCE6ajRI0J06ajQS8mRHBP8S8vAS8mQ6ajT////IxZDIxkEAAAAAAAEAAAAAAAAS8KgaqYQS9NzNYpsS8RjHuxMUBNoAAAcZAdwAAAAS8STIzZDNmNgAAEAS8WDHu7zHu4e6hxUAAAAS8dwAAAcAAAEAAAAS8TB6BMgS8fTNYptvzeX///7Hu4fIxOcUBNoAAAcZAdwAAAAAAAe6q80AAAAS8dwAAAcS8ZwS8bjNmNjHu4cS8gTIxkHIxf66hHEAAAdAewQS9DgAACQAAAEAAAAAAAAAAHD////////IxZDIxkES8ngAAAEAAAAAAAAS8agBD8QS9AjNYptgsH3///7Ixf7IGzEAAABAewQUBNoAAAcZAdwAAAcS82QAsCkAAAA6ajQS8lTKK+5AewQUBNoAAAcZAdwAAAAAAAES87hHNTBAewQUBNoAAAcZAdwS9AhHQT5HQUY6ajSgoKSAgID/AAAA/wD//wAAAP//AP8A//////+Yd0sImABFCBxIsKDBgwgTKkSYQYHDDQI1WFg4UCJBDQsugIAw4YOHBxUoivgYsmLGgRsdUgghwaGCCyMfOFjgUsFKgR9fDiQpQkMDDiIidPzYMWZJkwqK8hTYUAEDDkuXFmz5lCfGjhGqgsS59WDDDTwlPA06tKtUES0hioW6Ne1HrSXPBnUJc+6EDhAcYlAAtqvdDyIDCx5MWHBAADs=" title="Go!" alt="Start surfing" class="button" autofocus/>
form action="/includes/process.php?action=update" enctype="multipart/form-data"
onkeypress="return handleEnter(this, event)"
method="post" onsubmit="return updateLocation(this);" class="form">
the source for the check boxes are
input id="jsOnOff" name="js" type="hidden" value="0"/>
input type="checkbox" name="allowCookies" id="allowCookies" checked="checked">
label for="allowCookies" class="tooltip" onmouseover="tooltip('')" onmouseout="exit();">Allow Cookies</label>
<input type="checkbox" name="stripJS" id="stripJS" checked="checked">
label for="stripJS" class="tooltip" onmouseover="tooltip('')" onmouseout="exit();">Remove Scripts</label>
<input type="checkbox" name="stripObjects" id="stripObjects">
label for="stripObjects" class="tooltip" onmouseover="tooltip('')" onmouseout="exit();">Remove Objects</label>
and the source for the textbox is
input id="address_box" type="text" name="u" value="http://" size="42" onfocus="this.select()"/>
|
|
|
|
|
Come one! Read your post after you hit "Post Message"!
Don't put your entire post inside PRE tags.
|
|
|
|
|
Dear members and administrators,
Hello everyone, a pleasant day.
I've been studying C# for quite sometime and now I am doing a very simple Web application and a Web Service in which this Web Service will handle all database commands such as open, close, add a record, delete, and edit. So far, I am still stuck in opening a database.
This is the code of my Web Service, the file name is Service.asmx:
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data;
using System.Data.SqlClient;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
private const string connectionString ="Server=MARK\\SQLEXPRESS2005;Database=SampleDatabase;Trusted_Connection=True;";
string sqlQuery;
DataSet dataSet;
bool isConnectionFailed;
SqlConnection sqlConnection;
public Service () {
}
[WebMethod]
public void connectToDatabase(){
sqlConnection = new SqlConnection(connectionString);
try {
sqlConnection.Open();
isConnectionFailed = false;
}
catch (Exception exception) {
isConnectionFailed = true;
}
finally { }
}
[WebMethod]
public string getConnectionMessage() {
string message="";
if (isConnectionFailed)
message = "Error while connecting to Microsoft SQL Server.";
else
message = "Connection SUCCESSFUL!!!";
return message;
}
}
I tested it and it works fine.
Then I created a new Solution/Project, a Web Application in C#. Afterwards, I added my WebService as a Web Reference to this Web Project(or Solution). This is the code of Default.aspx.cs:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace WebProject
{
public partial class _Default : System.Web.UI.Page
{
WebServiceDatabase.Service service = new WebProject.WebServiceDatabase.Service();
protected void Page_Load(object sender, EventArgs e)
{
service.connectToDatabase();
lblConnectionMessage.Text = service.getConnectionMessage();
}
}
}
I tested it and it works fine. The web browser(IE) displays the string:
Connection SUCCESSFUL!!!
BUT, when I tried to disconnect/stop the service of my SQL Server and try to run again the Default.aspx, I am still recieving the same message (i.e. Connection SUCCESSFUL!!!). I should be expecting the error message, right?
Can anyone help me how would I change my webservice code?
Thank you and more power. God bless everyone.
Warm regards,
Mark
|
|
|
|
|
Caching can play bad tricks. Close the browser before you test again. It might be even necessary restart the IIS service.
|
|
|
|
|
can't him set the size of the connection pool to 0 in order to force a new connection every time? i don't think this will be good for production, but maybe can help him to discover the problem...
|
|
|
|
|
Most probably, your browser and/or the web server is sending you a cached response. Force a reload of the page with Ctrl+F5 and see.
|
|
|
|
|
marksquall wrote: I should be expecting the error message, right?
No.
And your scenario is wrong anyways so presumably you are only doing it to mess around.
C# (.Net) by default uses a connection pool for MS SQL Server connections.
So the first time you called it a new connection was created. That was put into the pool.
And it was put into the pool by the GC which is NOT a good idea. You should be explicitly closing it.
The second time you called it, the connection in the pool was used. Pooled connections are not verified (nor should they be). They only result in an error if they are actually used to interact with the database.
marksquall wrote: Can anyone help me how would I change my webservice code?
That would require more explanation of what you think you are attempting to do. But as one possibility you should be doing a do nothing query on every attempt to insure that the database itself is actually capable of doing work.
|
|
|
|
|
Thanks guys for your comments and suggestions, your information gives me more knowledge.
I had just put the connection, and all the database queries, in my .aspx.cs file for the meantime. My simple database Web application is running ok now, but I know it needs more improvements.
God bless you all.
Warm regards,
Mark
|
|
|
|
|
Can someone summarize the process going on ..what is mKey and mIV ....
I'm not from IT background ....so problem in understanding
Sandy
|
|
|
|
|
The Key is the actual data that will be used to encrypt or decrypt the whole message. Think of it as the "Password" to the message.
The IV is a set of random numbers used as a "salt" to start the encryption process.
If all your messages start the same way, then if you know the start of one message, it is easier for you to work out the key for a different message - because you know some of the data that made it up. The IV prevents that happening by providing a set of random numbers to start the encryption process, which vary from message to message. That is why they are transmitted in clear, normally as a block of bytes at the front of the message. Knowing the IV values gives you nothing if you are trying to hack the message - it is normally XORed with the first block of data before encryption so it becomes less readable. Subsequent blocks of data use the output from the first block to generate the IV for the second, and so forth.
If you are feeling particularly paranoid, then just prefix your actual data with a block full of random rubbish, so that by the time the encryptor gets to any duplicated data it has already mangled the IV to death...
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|