|
wow this must be the dumbest question i've ever asked here...
I could just use the mouseclick event, problem solved
|
|
|
|
|
Hello!
I am quite new to programming. I have no ideea how to cancel these 'automatic' key events that rise from hiting 'enter' or 'space' on a button but here is how i would do it:
Set button's 'TabStop' to false. Create an 'enter' event and put this inside the event:
SelectNextControl(yourbuttoncontrolhere, true, true, true, true);
This won't allow the user to focus the control in any way but it will allow him to click the button.
Hope this helps,
Good luck!
|
|
|
|
|
I dont understand why you fired button1_Click event....just fired button1_MouseClick event that's it..
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
my application is Port Listener(window service)
a lot of client will send data to this port in order to handle it i have used mutithreading.
After receiving data from port i have to save it in database now i m using
classical way to save in database
like open connection save data and then close connection and dispose connection.
as we know every time opening and closing connection take time .
Because within a second 30 or more than 30 client is sending data to this port to this port every time opening closing connection is not idea.
so please suggest how to use one connection for all request first time only it open connection and from next time my app use the open connection.
modified on Tuesday, December 22, 2009 8:05 AM
|
|
|
|
|
I don't understand your question if there is any question.
Shivendra Pandey wrote: It means only first time the database will open from next time it use the same open connection for every request.
As long Connection is opened it will be used for request. However you need to handle connection timeout (Disconnected by unkown reasons).
Shivendra Pandey wrote: one dedicated open connection for all request in this service
If you use app or service as "front end" (app that sits on server and it is betwen client and database) and connect to database service than that can be acheaved. That app needs to handle a multiple connection if you want to use multiple clients at the same time
|
|
|
|
|
So where is the problem? Its easy enough to do.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Probably you don't want that.
For example, if the connection is lost, what happens?
If two clients try to use the connection at the same time? One client starting a transaction will in fact be starting a transaction over the connection used by everyone (for example, in Sql Server if there is a transaction, you must use it).
And, finally, there is the connection pooling. By default, when you open and close a connection, the real connection keeps opened, but it is returned to the pool. Opening it again will only use the already opened connection. So, the best practice is to open the connection for each web-method and close it at the end. You can, of course, configure the maximum pool size to 1, so only one real connection will be kept open.
|
|
|
|
|
i think u should create and open the connection when your windows service starts,so during the process everywhere in your code u can use that open connection.
|
|
|
|
|
hi to all,
I am working in windows DatagridView,i assigning value through the Datasource, but in the grid also having the combo box where values are populated from the dataset. At the runtime, if i am click the grid, it throws the error like ='Datagridviewcomboboxcell value is not valid' .
Anyone can help me!!!
Regards
srikanth
|
|
|
|
|
|
Hi Team,
I have two textboxes for taking startdate and enddate.
If I give start date 10/01/2009 and Enddate 10/12/2009 then report should display 01st - 12th Oct'09
If start date is 10/02/2009 then it should display 02nd -12th Oct'09
Kindly help me
|
|
|
|
|
This question connect to other post
Date Time String formats[^]
String str1 = DateTime.Now.ToString("dd");
String str2;
if (str1 == "01")
str2 = "st"
else if (str1 == "02")
str2 = "nd";
else if (str1 == "03")
str2 = "rd";
else
str2 = "th";
String str3 = DateTime.Now.ToString("MMM");
String str4 = DateTime.Now.ToString("yy");
String date = str1+str2+ " " + str3+ "'"+ str4;
This task is dead easy. I showed how i did get custom format. Normal string formating doesn't show "st, nd, rd, th" (At least I think that whay) and doesn't allow chars as "'"
Edit: Pre tags added
|
|
|
|
|
Instead using else if I prefer using switch .
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
i woud use else if because it is small code. I would use Switch for bigger operation
|
|
|
|
|
I prefer switch for small and bigger cases.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
SqlConnection thisConnection = new SqlConnection(<br />
@"Server=(local);Integrated Security=True;" +<br />
"Database=northwind");<br />
NOW the server is "local",but when i Install my Program on pc1,install DATABASE on pc2,how can i use date from pc2? i can not change server everytime,i think it can read from a comboBox?how can i do?
|
|
|
|
|
You could build the connection string dynamically depending on which server you want to use.
If this answer makes no sense to you, please elaborate your question
|
|
|
|
|
if you use "pc2" instead of "(local)" your app will work what ever machine it is running on. Better to hold the connection string in a config file and provide a means to configure it within your app.
|
|
|
|
|
if you are running program on pc1 and installed database on PC2 then you shoud use connection string as below.
SqlConnection thisConnection = new SqlConnection(
"Server=pc2 IP or pc2 Name;Integrated Security=True;
Database=northwind");
|
|
|
|
|
You can use DataLink to create connection from any workstation to database server...code snippets like
MSDASC.DataLinks ObjDLink;
ObjDLink= new MSDASC.DataLinks();
ObjPrompt = ObjDLink.PromptNew();
strConnectioString = ObjPrompt.ToString();
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
My offer ,else use MSDASC class
now see what is my offer..
1- Server side:
Run Sql Server browser Service in your database server machine, then
create Valid login for your database,set sql server authentication to Windows and SQL athentication
2- Application side:
with a form like this:
http://privateimage.com/images/9fq89vuk7uokjz8koz.jpg
and with functions like below for buttons
private void btnSearch_Click(object sender, EventArgs e)
{
SqlDataSourceEnumerator SqlEnumerator = SqlDataSourceEnumerator.Instance;
DataTable dt = new DataTable();
dt = SqlEnumerator.GetDataSources();
dataGridView1.DataSource = dt.DefaultView;
}
private void btnSave_Click(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count != 0)
{
string ConString = "";
SqlConnectionStringBuilder builder =new SqlConnectionStringBuilder();
builder.ApplicationName = "MyApp";
builder.WorkstationID = Environment.MachineName;
builder.UserID = txtLoginName.Text.Trim();
builder.Password = txtPassword.Text.Trim());
builder.InitialCatalog="MyDBName";
builder.DataSource = dataGridView1.SelectedRows[0].Cells["ServerName"].Value.ToString()+
"\\"+dataGridView1.SelectedRows[0].Cells["InstanceName"].Value.ToString();
ConString = builder.ConnectionString;
}
}
at the end your data link string is ConString variable, you can store it in encrypted file or registry. each time application start check stored connection, and if failed retry this form
note: used namespace are:
using System.Data.Sql;
using System.Data.SqlClient;
hope helps with ugly sample
modified on Friday, December 25, 2009 9:45 AM
|
|
|
|
|
I'm attempting to create several ComboBox controls on a windows form that are all connected to a relational database. The controls "narrow" their selection choices when any other given ComboBox is selected to an item.
Similar to say..narrowing down a motherboard model by selecting Intel/AMD --> Socket --> Chipset --> etc. As I'm quite new to working with data in C#, I was hoping someone could offer a good reference that I can use to read up on this - preferably, a beginner's reference.
Help is appreciated. =]
|
|
|
|
|
Hi Team
I need to show date in this format in my report -----------Dec'09
I am getting format like this Dec2009 for this I am using (MonthName(Month(Parameters!sdate.Value),TRUE)& Year(Parameters!sdate.Value))
Please kindly help me how to get format Dec'09 and also
How to display previous month date also Nov'09 (Need formula)
|
|
|
|
|
String date = DateTime.Now.ToString("MMM yy");
However it will return exception if you want " ' " char to be seen.
siddisagar wrote: How to display previous month date also Nov'09 (Need formula)
String date = DateTime.Now.AddMonths(-1).ToString("MMM yy");
|
|
|
|
|
I am using Sqlite in an application.
Was wondering if anybody knows limitations on the number of characters one can have when labelling a column as being of type(/affinity) TEXT?
|
|
|
|