|
|
thank you very much my friend you helped me a lot...
the magic was in the [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
before the Properties of the instance of the first class ...
any way thank you again.
best regards
|
|
|
|
|
Don't use TXTspeak in the forums. You've got a 101+ key keyboard in front of you. Use it.
TXTspeak makes you look unprofessional and immature.
|
|
|
|
|
Hello Everybody,
I am developing an Application using Database. I am Opening Database Connection at the time of Loading.
and I am Closing Connection at the time of Closing application.
So I want to know that
Open And Close Connection Every Execution is Good or
Open Connection Only One Time is good.
Thanks
If you can think then I Can.
|
|
|
|
|
Normally you'd do the first (though you might execute several related SQL statments in one block), and keep the connection open for the shortest time possible.
The SQL server has a finite amount of connections, keeping one open blocks it "permanently".
If you are worried about perfomance, you can probably cache some data on the SQL client. Another thing to do is to set the pooling attribute to true, which reduces the overhead induced when creating connection objects. You must close the connection to return them to the pool. See http://msdn.microsoft.com/en-us/library/8xx3tyca(v=vs.71).aspx[^] for some details.
[edit]
This[^] explains how and why it works a little better.
|
|
|
|
|
What Keith says is correct, I'd just like to add that while you can open once and leave the connection open on single user databases, even there it is not recommended as it blocks access to the file for backup purposes. MS Outlook used to do that, and it always made backups fail because the contacts database file was permanently in use. PITA!
Open - transact - close - dispose. Every time!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
I think both are Correct according to Database Use.
But My requirement is for Single Database Connection in Local Machine (not in web). Both are (Open Connection only one time and Open Close Connection ) Working Fine.
But i m still waiting for result which one is best.
Thanks
If you can think then I Can.
|
|
|
|
|
As Keith and I both said: the best solution is allways to "Open - Transact - Close - Dispose".
Do not keep the database open.
Even for a local database, other software such as backups cannot access the file if you hold the connection open.
Both "Open Once" and "Open - Transact - Close - Dispose" will appear to work the same, but the affects are not apparent in isolation: in the real world holding a database open can cause problems and is a bad thing to do.
It is also worth treating local databases as if they were networked resources: if you have to change your program to accommodate an expanded user base, there is almost no code to change!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
Thanks Sir
If you can think then I Can.
|
|
|
|
|
Welcome!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
|
I store my application settings in the usual Settings.setting & user.config files. These end up getting saved in:
C:\Users\xxx\AppData\Local\yyy\zzz.vshost.exe_Url_4tl3bgapsgf1jhafbqp4hhoyrvqsqsqz\1.0.0.0\user.config
Now, I just switched my AssemblyInfo.cs to use auto build incrementing:
[assembly: AssemblyVersion("1.32.*")]
Now, the settings get wiped out with *every* build. Obviously, because its getting stored in a new location.
C:\Users\xxx\AppData\Local\yyy\zzz.vshost.exe_Url_4tl3bgapsgf1jhafbqp4hhoyrvqsqsqz\1.32.4101.21730\user.config
C:\Users\xxx\AppData\Local\yyy\zzz.vshost.exe_Url_4tl3bgapsgf1jhafbqp4hhoyrvqsqsqz\1.32.4101.28773\user.config
Is there any way around this? So the user.config doesn't get wiped out?
|
|
|
|
|
Found the obscure answer to this issue, lol. You need to call this pretty early on:
Properties.Settings.Default.Upgrade();
|
|
|
|
|
Whoa. Never even heard of that one. Thanks. It'll come in handy.
(Everyone stop laughing at me...there's lots I don't know.)
|
|
|
|
|
Hi,
I wanted to show my gamil inbox on C# form just like gmail inbox.
How can I do that?
Please, help me.
|
|
|
|
|
You can use webbrowser control. Make it login automatically when program starts. Or you could even use outlook APIs..not sure about it though. But I've used auto login using browser control. take a look at code below. I used this code to automate login for gmail only. But it will stop working if google changes their source codes.
Login.Enabled = false;
brs = new WebBrowser();
HtmlElement idBox = brs.Document.GetElementById("Email");
HtmlElement passBox = brs.Document.GetElementById("Passwd");
idBox.InnerText = ID.Text;
passBox.InnerText = PASS.Text;
HtmlElement button = brs.Document.GetElementById("signIn");
button.InvokeMember("click");
|
|
|
|
|
There are APIs and feeds which will be much less brittle if Google changes stuff.
(see my post below)
|
|
|
|
|
Take a look here[^]
Gmail has a readonly atom feed, and supports industry standard IMAP and SMTP if you want to send stuff.
|
|
|
|
|
|
If you want to do this job
connect your gmail account using Microsoft Outlook Express
and then create a windows application using c#
refer Microsoft.Office.Interop.Outlook.dll
and the monitor your mail and display those things in your Form.
|
|
|
|
|
Hi community, i'm needing some help with C# and ASP.NET, mostly C# that's why i posted here.
I got this form in my login.aspx.
<form id="login_form" action="" method="post">
<label>Email:</label>
<label>Password:</label>
<input type="text" name="login_email" id="login_email" />
<input type="password" name="login_password" id="login_password" />
<button id="login_button" type="submit">Login</button>
<a href="#">¿Forgot password?</a>
</form>
And also i added a database with the SQL EXPRESS.
I got the login.aspx.cs with this code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Sql;
using System.Data.SqlClient;
public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
private void login_button(object sender, EventArgs e)
{
SqlConnection connection = new SqlConnection();
connection.ConnectionString = "Server=(local)\\SQLEXPRESS;" + "user ID=myuser; Password=mypassword;" + "Database=mydatabase";
try
{
connection.Open();
}
catch (Exception)
{
}
}
}
Now the question is, how can i get HTML elements with the C#, so then i make the "SELECT Email, Password FROM tblUsers WHERE Email='input_user" AND Password='input_password'" being input_user and input_password C# strings.
login_button is the ID of the submit button in ASP.NET.
How do i join all this? Getting the number of rows after making the query, like in PHP when you make the $row = sql_query("WHERE...") and returns the number of rows, if $rows == "1", it means that the pair "email and password" exists, so login access is granted.
Thanks for everything!
Hope you can help me!
Marian.
|
|
|
|
|
I suggest you move this to the ASP.NET forum (copy there and delete this). You should probably be using ASP.NET web controls in place of the HTML, unless you are using the MVC framework
|
|
|
|
|
Hi,
I've just started to learn multi-threading. I'm trying to make a console program that makes a web browser and then navigate to some page and post some data and invoke submit button and in method it waits for the response of the web browser. I'm using code below, could someone tell me how to do it correctly.
private AutoResetEvent ar;
private WebBrowser brs;
[STAThread]
private void Contribute_Load(object sender, EventArgs e)
{
ar = new AutoResetEvent(false);
brs = new WebBrowser();
brs.Url = new Uri("http://www.gmail.com");
brs.Navigated +=new WebBrowserNavigatedEventHandler(brs_Navigated);
ar.WaitOne();
Console.WriteLine("Navigated to gmail.com");
}
void brs_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
ar.Set();
}
This code never prints navigated to gmail.
Thank you
Shivam
|
|
|
|
|
this can't work, your Load handler is running on the main (aka GUI) thread and so is the Navigated handler; this means the Navigated handler will not execute as long as the Load handler hasn't finished. You are deadlocked. Most often it is a bad idea (or plain wrong) to have blocking calls (such as Thread.Sleep or AutoResetEvent.WaitOne) inside an event handler.
probable solution: end your Load handler with the navigation command (you should first set the Navigated handler, then the URL); put everything that needs to be done after navigation in the Navigated handler. That is what it is for.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hi. Thanks for the quick response.
I've just started learning thread on c sharp. So could you please explain more?
Basically I want a method "ValidateStudent" that will create a webbrowser object, navigate to school's website then post ID and Password and check if login succeed. But during this whole process the method should wait.
private bool nav = false;
private WebBrowser brs;
public ValidateStudent()
{
ar = new AutoResetEvent(false);
ar1 = new AutoResetEvent(false);
brs = new WebBrowser();
brs.Navigated += new WebBrowserNavigatedEventHandler(brs_Navigated);
brs.Url = new Uri("https://rooms.library.dc-uoit.ca/studyrooms/myreservations.aspx");
Console.Write(nav);
}
private void brs_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
nav = true;
}
This code is printing "False" because it does't wait for event to complete and prints "False" instantly. I want it to wait until event completes.
THANK YOU
Shivam
|
|
|
|