|
20 is just a example. Why second client wait due to first client when call same metod in WCF.
|
|
|
|
|
How are you starting your service host? Are you using a single instance of the service class or are you passing the service type to the ServiceHost constructor?
In the service code, there is some call to synchronization methods or some external API that could cause concurrent execution to block?
Edit: another possibility: are you executing SQL queries with transactions?
modified on Monday, October 19, 2009 6:37 AM
|
|
|
|
|
hi, I created a custom control and put textboxes in it.Even though I can use the events of textboxes, I can't use the events of the custom control itself. Any way to do it? Thanks
|
|
|
|
|
So long as you subscribe to the events properly and attach handler methods it should be no problem
using System;
using System.Drawing;
using System.Windows.Forms;
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
MyControl myControl = new MyControl();
Controls.Add(myControl);
myControl.BackColorChanged += new EventHandler(myControl_BackColorChanged);
myControl.BackColor = Color.Black;
}
void myControl_BackColorChanged(object sender, EventArgs e)
{
MessageBox.Show("Handler for myControl");
}
}
public class MyControl : UserControl
{
public MyControl()
{
BackColorChanged += new EventHandler(MyControl_BackColorChanged);
}
void MyControl_BackColorChanged(object sender, EventArgs e)
{
MessageBox.Show("Handler for own event");
}
}
|
|
|
|
|
Thanks for the code Dave but I think I couldn't explain well.Here is more detail;
I created a custom control and put a normal textbox in it and placed this custom control on a form. When the form is running, all I want is When I click on the textbox, I want to use the click event of the custom control,not the textbox.
thanks
Also, I use singleton for the form if that differs
|
|
|
|
|
When you click in that textbox, only the textbox's Click event is going to fire. You didn't click on the surface of the custom control so its Click event won't fire. In order for the Form to see the TextBox's Click event, you're going to have to handle the Click event in your custom control and, in that event handler, Raise your custom controls Click event.
|
|
|
|
|
|
I have an application that is (should) save blobs in the database. It saves all the columns except the blob. I have been trying everything I can think of. If anyone has something to try, please let me know. I keep telling myself this should not be hard. Thanks in advance.
Here is the table (SQL Server 2005).
CREATE TABLE [dbo].[publication] (
[id] INT IDENTITY(1,1) NOT NULL,
[title] VARCHAR(50),
[category] VARCHAR(50) NULL,
[orig_file_name] VARCHAR(255) NULL,
[publish_date] DATETIME NOT NULL DEFAULT(GETDATE()),
[data] IMAGE NOT NULL,
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
Here is the code.
public static int uploadPublication(string title, string originalFileName, DateTime publishDate, string category, System.IO.Stream publication)
{
byte[] publicationData = new byte[publication.Length];
publication.Read(publicationData, 0, Convert.ToInt32(publication.Length));
SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ClubSiteDB"].ConnectionString);
SqlCommand command = new SqlCommand("INSERT INTO publication (title, orig_file_name, publish_date, data, category) VALUES ( @title, @orig_file_name, @publish_date, @data, @category); select SCOPE_IDENTITY()", connection);
SqlParameter param0 = new SqlParameter("@category", System.Data.SqlDbType.VarChar, 50);
param0.Value = category;
command.Parameters.Add(param0);
SqlParameter param1 = new SqlParameter("@title", System.Data.SqlDbType.VarChar, 50);
param1.Value = title;
command.Parameters.Add(param1);
SqlParameter param2 = new SqlParameter("@orig_file_name", System.Data.SqlDbType.VarChar, 255);
param2.Value = originalFileName;
command.Parameters.Add(param2);
SqlParameter param3 = new SqlParameter("@publish_date", System.Data.SqlDbType.DateTime);
param3.Value = publishDate;
command.Parameters.Add(param3);
SqlParameter param4 = new SqlParameter("@data", System.Data.SqlDbType.Image);
param4.ParameterName = "data" ;
param4.Value = publicationData;
command.Parameters.Add(param4);
connection.Open();
object result = command.ExecuteScalar();
connection.Close();
if (result != null)
{
return Convert.ToInt32(result);
}
else
{
return 0;
}
}
|
|
|
|
|
|
Thank you very much for the link. The my code is almost line-for-line the same as the example article. Still does not help my problem.
|
|
|
|
|
Then take a closer look. The difference is, mine works, yours doesn't.
only two letters away from being an asset
|
|
|
|
|
Hello all,
Where is what I have done:
1. I have a database(MySQL) with one table.
2. I have my data source made in visual studio(2008)
3. I drop the table unto my form.
So right now I am able to move between records and can add/deleted/update records using the buttons on the binding Navigator control.
But when I add a button to the form to move between records nothing happens. Here is the code I did for the button
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
<br />
this.BindingContext[this.empDataSet, "employees"].Position++;<br />
<br />
<br />
}<br />
Is there a way that I can use both the Navigator control, and use my own buttons at the same time?
|
|
|
|
|
I am not sure, but I think
this.BindingContext[this.empDataSet, "employees"].Position++;
is just a result. You must be initialize this result to navigator control related property.
Best Regards...
|
|
|
|
|
Well the navigator control buttons work.
But am trying to do the samething, but with a normal button.
|
|
|
|
|
Hi.
Ive tried googling for some time now, but havent come across anything that might lead to a solution to my "problem". I guess I aint using the right search phrase.
What I am looking for, is a way to show items on top of a fullscreen playing video. That means, I want listboxes, textfields and alike to show up on top of the video, and these items/elements can be dragged around by the user. The elements should be usable ofc.
Any ideas on what to look for? Or even better, an example?
Thanks alot
|
|
|
|
|
AFAIK you can only do this with WPF
only two letters away from being an asset
|
|
|
|
|
Thank you, I will look into it
|
|
|
|
|
I want to be able to pass a string into this procedure to send emails to more than one person. What am I doing wrong?
I keep getting an error that email.cc and email.to are read only fields.
I have tried to pass the parameter into the email = new MailMessage (mailFrom,MailTO)
however I only am able to pass 1 email address into it. I need to be able to pass 7 email addresses into the 1 message. How do I do this?
public static string NET_AuthenticatedMailSend(string mailFrom, string mailTo, string Subject, string MessageBody, string smtpHost, int smtpPort, string smtpNETAuthUser, string smtpNETAuthPassword)
{
MailAddressCollection MailTO = mailTo;
MailAddress MailFROM = Convert. mailFrom;
System.Net.Mail.MailMessage email = new MailMessage();
email.From = MailFROM;
email.CC = MailTO;
email.Subject = "VERSION CONTROL (AUTORESPONDER): " + Subject;
email.IsBodyHtml = true;
email.Body = "VERSION CONTROL (AUTORESPONDER): \n\r" + MessageBody;
System.Net.Mail.SmtpClient mailClient = new SmtpClient();
System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential(smtpNETAuthUser, smtpNETAuthPassword);
mailClient.Host = smtpHost;
mailClient.Port = smtpPort;
mailClient.UseDefaultCredentials = false;
mailClient.Credentials = basicAuthenticationInfo;
try
{
mailClient.Send(email);
}
catch (Exception ex)
{
MessageBox.Show("Error Sending email: " + ex.ToString());
return ex.ToString();
}
return "1";
}
|
|
|
|
|
JollyMansArt wrote: I have tried to pass the parameter into the email = new MailMessage (mailFrom,MailTO)
however I only am able to pass 1 email address into it. I need to be able to pass 7 email addresses into the 1 message. How do I do this?
CC, To is a collection of email address.
Use the Add Method of the CC and To Object to add email address(s).
If you want to add multiple addresses, call the add method multiple times with different email addresses.
Hope this helps.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
JollyMansArt wrote: I keep getting an error that email.cc and email.to are read only fields.
RTFM. They are collections, you have to add to them, not assign them.
JollyMansArt wrote: I have tried to pass the parameter into the email = new MailMessage (mailFrom,MailTO)
Again, RTFM! MailTO is a collection and there are no constructors for MailMessage taht take a collection.
only two letters away from being an asset
|
|
|
|
|
in my program i am developing login for user for standalone system
here i check the condition whether the user is valid or not ?
In my data base i store some name and passward and check whethre it present in database or not but my prog check only one user eg. Admin and passward
ie. problem in condition checking i want prog. who check other user also ie. if i type diffrent user name such as xyz and pssw. too so how i check this value in data base .
Here is my code:-
namespace loginscreen
{
public partial class Form1 : Form
{
OleDbCommand cmd = new OleDbCommand();
OleDbConnection con = new OleDbConnection();
String Path = "Provider= Microsoft.Jet.OLEDB.4.0; Data Source= C:\\sms.mdb; Persist Security Info=False";
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
con = new OleDbConnection(Path);
cmd = new OleDbCommand(" select * from login ", con);
con.Open();
OleDbDataReader reader = cmd.ExecuteReader();
string usernamedb, passwarddb;
string passwardtxtbx, usernametxtbx;
usernametxtbx = tbName.Text.ToString();
passwardtxtbx = tbPassward.Text.ToString();
while (reader.Read())
{
usernamedb = (reader.GetString(0));
passwarddb = (reader.GetString(1));
if (tbName.Text == "Admin")
{
if (tbName.Text == reader.GetString(0))
{
if (tbPassward.Text == reader.GetString(1))
{
MessageBox.Show("login successfully");
return;
}
else
{
MessageBox.Show("Try Again");
return;
}
} }
}
con.Close();
}
}
}
|
|
|
|
|
Hi,
IMO that is not the right way to do login checks; you should not read the entire table and iterate it.
this is what I would do:
1. have a table with fields username, and password
2. form the user login attempt, take the username and the password;
3. now do a "SELECT * WHERE username='"+username+"' AND password='"+password+"'"
(better yet use parameterized SQL)
4. you now either get 0 or 1 row returned, that tells you the user/password combination is unknown or known
Improvements:
- do not store passwords as text, use some encryption or hashing, and store or search the result thereof.
- better yet, apply a salt[^].
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
|
|
|
|
|
Here is a test console application that works:
using System;
using System.Collections.ObjectModel;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using Microsoft.Office.Interop.Excel;
namespace ConsoleApplication3
{
class Program
{
static void Main()
{
Application app = new Application();
app.Visible = true;
app.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
Runspace runspace = RunspaceFactory.CreateRunspace();
runspace.Open();
runspace.SessionStateProxy.SetVariable("Application", app);
Console.WriteLine(app.Version);
Pipeline pipeline = runspace.CreatePipeline("$Application");
Collection<PSObject> results = null;
try
{
results = pipeline.Invoke();
foreach (PSObject pob in results)
{
Console.WriteLine(pob);
}
}
catch (RuntimeException re)
{
Console.WriteLine(re.GetType().Name);
Console.WriteLine(re.Message);
}
}
}
}
I first create an Excel.Application instance and pass it to the hosted PowerShell instance as a varible named $Application. This works and I can use this variable as if Excel.Application was created from within PowerShell.
I next created an Excel addin using VS 2008 and added a user control with two text boxes and a button to the addin (the user control appears as a custom task pane when Excel starts). The idea was this: when I click the button a hosted PowerShell instance is created and I can pass to it the current Excel.Application instance as a variable, just like in the first sample, so I can use this variable to automate Excel from PowerShell (one text box would be used for input and the other one for output. Here is the code:
using System;
using System.Windows.Forms;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Collections.ObjectModel;
using Microsoft.Office.Interop.Excel;
namespace POSHAddin
{
public partial class POSHControl : UserControl
{
public POSHControl()
{
InitializeComponent();
}
private void btnRun_Click(object sender, EventArgs e)
{
txtOutput.Clear();
Microsoft.Office.Interop.Excel.Application app =
Globals.ThisAddIn.Application;
Runspace runspace = RunspaceFactory.CreateRunspace();
runspace.Open();
runspace.SessionStateProxy.SetVariable("Application", app);
Pipeline pipeline = runspace.CreatePipeline(
"$Application | Get-Member | Out-String");
app.ActiveCell.Value2 = "Test";
Collection<PSObject> results = null;
try
{
results = pipeline.Invoke();
foreach (PSObject pob in results)
{
txtOutput.Text += pob.ToString() + "-";
}
}
catch (RuntimeException re)
{
txtOutput.Text += re.GetType().Name;
txtOutput.Text += re.Message;
}
}
}
}
The code is similar to the first test, except that the current Excel.Application instance is available to the addin via Globals.ThisAddIn.Application (VSTO generated) and I can see that it is really a Microsoft.Office.Interop.Excel.Application instance because I can use things like app.ActiveCell.Value2 = "Test" (this actually puts the text into the active cell). But when I pass the Excel.Application instance to PowerShell, what gets there is an instance of System.__ComObject and I can't figure out how to cast it to Excel.Application. When I examine the variable from PowerShell using $Application | Get-Member this is the output I get in the second text box:
TypeName: System.__ComObject
Name MemberType Definition
---- ---------- ----------
CreateObjRef Method System.Runtime.Remoting.ObjRef CreateObj...
Equals Method System.Boolean Equals(Object obj)
GetHashCode Method System.Int32 GetHashCode()
GetLifetimeService Method System.Object GetLifetimeService()
GetType Method System.Type GetType()
InitializeLifetimeService Method System.Object InitializeLifetimeService()
ToString Method System.String ToString()
Is there a way to pass an instance of Microsoft.Office.Interop.Excel.Application from a VSTO generated Excel 2007 addin to a hosted PowerShell instance, so I can manipulate it from PowerShell?
(I have previously posted the question on StackOverflow[^], and the best answer I got was to use InvokeMember, which works, but is not what I'm after.)
Thank you in advance.
»Prosti mja u moemu nedoumeniu što ciniti! Razsuždaj: najdoh se u nuždi! Ne prolivaj slezi! Obresti li budu az i polk put k dalšoj blagozracnoj Denici? I moj dolgi život projde aki kratcje žitie. I kamo az pojdu ... gorkost smerti vižu ...«
|
|
|
|
|
Dear All,
I have parent and subreport in win form which uses Report Viewer and RDLC as Reporting Tool.
Every thing is fine as I can pass parms to both Parent and child, the only problem I face is that suppose that i am getting two records from parent with ID 1 and 2 and each of them has children with 5 records.
What i want is the Main and Subpreport should follow the following rule.
Parent Details
Id Code Discription
1 01 One // this is the first Record from Sql Statement passed
Child Details
ChildId Description //SubpReport
1 One
2 Two
. .
. .
. .
2 01 Two // this is the second Record from Sql Statement passed
Child Details
ChildId Description //SubReport
1 One
2 Two
. .
If i select single record from parent and get the child records, it shows ok
but getting more than one records from parent and the same whith child, it shows a very messy report. while i want above format
any ideas please?
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
The only thing that I could think of is that you may want to pass the IDs through a single parameter to the child report. When you build your SQL Query for the parent report, one of the columns that are returned could contain ALL the child IDs (separated by a comma). Then through a subreport parameter you could transfer this parameter that contains all the child IDs into the query for the subreport.
I think this could be accomplished a lot easier if you use the RDLReportViewer[^] control instead of having to write all that .NET code to accomplish this. With using the RDLReportViewer[^] control you can just simply create a parent and child RDL file and the RDLReportViewer[^] control could easily show the RDL reports by telling the RDLReportViewer[^] control what report to show. It will automatically run all the queries and display the user parameters[^]. Check it out...
Chris
|
|
|
|
|