|
Thank you - that is interesting. I do wonder though, when you say "If in doubt..." - what doubt? Under what circumstances then would one prefer the other option (a single open/close outside the loop)?
|
|
|
|
|
|
Indeed, I could, but I don't expect a huge (or even noticeable) difference in performance with the size of databases I'm working with at the moment. I just wondered if one method was considered "best practice", really, and is maybe more scalable as the size of the database grows over time... MY gut feeling prefers, like you, to have each command wrapped in its own connection, but the other half of my gut (!) feels uneasy about opening and closing a hundred or so connections in such quick succession... it feels like a lot of unnecessary work. But if pooling is about minimizing this work, then good... (hence why I started off by saying I've never really understood (the guts) of pooling...)
|
|
|
|
|
A_Griffin wrote: but the other half of my gut (!) feels uneasy about opening and closing a hundred or so connections in such quick succession... After implementing a scenario where that actually happened, I'm not.
A Dokan-drive is something that shows up and acts like a drive in Windows Explorer (including any save-dialog), with the implementation of fetching the data left to the programmer. Clicking on a folder in Windows Explorer would launch a whole lotta operations - it would first want to know if there is such a file or folder, then a request to get its contents, then a request for each file in there, so it could display a size and icon. And the virusscanner requesting those files too, since they were being accessed.
Each operation, in VB.NET, would open and close a connection on my local machine, with a local database-server. The speed was limited by the capabilities of the Dokan-driver, not the speed of the database or opening/closing connections.
A_Griffin wrote: I don't expect a huge (or even noticeable) difference in performance with the size of databases I'm working with at the moment. ..then fill a table with 2 million records. Generate some nonsense-data in a loop and give it a try.
If your boss asks why you choose one or the other, it is better to present an experiment than to point to some idiot on the internet
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I said "NEW"; pooling is not making "new" connections.
I also didn't limit the number of connections from a single client to multiple servers / devices.
I also didn't specify "database servers" (SQL or otherwise); or only "client and (one) server".
TCP/IP is not limited to "databases".
A "new" TCP connection (first or a reconnect) requires hand-shaking not incurred once the connection is "open".
"Databases"? ok .. You get it by default; no thinking there.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Gerry Schmitz wrote: I said "NEW"; pooling is not making "new" connections. Obvious to both of us, but not to the casual reader who just sees "New Connection()".
Gerry Schmitz wrote: I also didn't specify "database servers" (SQL or otherwise); or only "client and (one) server". Would not need to, anything behind the abstraction of the Data Provider is irrelefant.
Gerry Schmitz wrote:
TCP/IP is not limited to "databases". ..I did not imply such.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
How to get each items "valuemember" value of checkedlistbox using for loop and show it in messagebox in winform
|
|
|
|
|
|
I need a OneWire Library to use in vb.net 2017.
a library wich Had emplimented the hole protocol as do Dallas for Ardino .
Thanks to your helps .
|
|
|
|
|
|
I need one implement the ptotocol in vb.net these are using he protocol.
thanks to your help.
|
|
|
|
|
Hi All, Hope you all Fine
I Create a controller (Account ), with 3 Action Result(Main Login Page,Login,register)as the bellow code:
public class AccountController : Controller
{
public ActionResult MainLoginPage()
{
return View();
}
public ActionResult Login()
{
return View();
}
[HttpPost]
public ActionResult Login(UserInfo user)
{
if (Membership.ValidateUser(user.UserName, user.Password))
{
FormsAuthentication.SetAuthCookie(user.UserName, false);
return RedirectToAction("HomePage", "Home");
}
else
{
ModelState.AddModelError("", "Login details are wrong.");
}
return View(user);
}
public ActionResult Register()
{
return View();
}
[HttpPost]
public ActionResult Register(UserInfo user)
{
if (ModelState.IsValid)
{
Membership.CreateUser(user.UserName, user.Password, user.Email);
return RedirectToAction("HomePage", "Home");
}
else
{
ModelState.AddModelError("", "already registered.");
}
return View();
}
I create one main View(MainLoginPage)which contain two Partial Views(_login,_Register) as follow:.
@{
ViewBag.Title = "MainLoginPage";
}
@section PageHeader
{
<link href="~/Content/Css/Login.css" rel="stylesheet" />
<link href="~/Content/Css/animation.css" rel="stylesheet" />
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
}
<pre>
<div class="wrapper">
<div id="login" class="animate form">
@{
Html.RenderPartial("_Login"); }
</div>
<div id="register" class="animate form">
@{ Html.RenderPartial("_Register"); }
</div>
</div>
_Login
@model myWebsite.Models.UserInfo
@using (Html.BeginForm("Login", "Account", FormMethod.Post))
{
<pre>
@Html.AntiForgeryToken() @*The anti-forgery token can be used to help protect
your application against cross - site request forgery.*@
@Html.ValidationSummary(true, "Login Failed, check details");
<label data-icon="u"> </label>
@Html.TextBoxFor(user => Model.UserName, new { placeholder = "username" })
@Html.ValidationMessageFor(user => Model.UserName)
<label data-icon="p"> </label>
@Html.PasswordFor(user => Model.Password, new { placeholder = "password" })
@Html.ValidationMessageFor(user => Model.Password@*,"*"*@)
_Register
code similar to Login
When login with valid user it work probably but My problem is when in enter invalid login details it showing the following Error:
Server Error in '/' Application.
The view 'Login' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Account/Login.aspx
~/Views/Account/Login.ascx
~/Views/Shared/Login.aspx
~/Views/Shared/Login.ascx
~/Views/Account/Login.cshtml
~/Views/Account/Login.vbhtml
~/Views/Shared/Login.cshtml
~/Views/Shared/Login.vbhtml
It seem that searching for the view login while login is Partial(_Login)
Could You please advice me
Note:
Quote: It work probably when I work on it as normal view not as partial view
modified 6-Jul-17 7:27am.
|
|
|
|
|
When you call the View method[^] without specifying a view name, it tries to find a view that matches the action name. You can see the list of views it looked for in the error message.
The problem is, you don't have a view called either Login or Register , so when you call View from those actions, it won't be able to find a matching view.
You can either add the missing views:
Login.cshml:
@{
ViewBag.Title = "Login";
}
@section PageHeader
{
<link href="~/Content/Css/Login.css" rel="stylesheet" />
<link href="~/Content/Css/animation.css" rel="stylesheet" />
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
}
@{ Html.RenderPartial("_Login"); }
Register.cshtml:
@{
ViewBag.Title = "Register";
}
@section PageHeader
{
<link href="~/Content/Css/Login.css" rel="stylesheet" />
<link href="~/Content/Css/animation.css" rel="stylesheet" />
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
}
@{ Html.RenderPartial("_Register"); }
Or, you can specify the view name:
public class AccountController : Controller
{
public ActionResult MainLoginPage()
{
return View();
}
[HttpPost]
public ActionResult Login(UserInfo user)
{
if (Membership.ValidateUser(user.UserName, user.Password))
{
FormsAuthentication.SetAuthCookie(user.UserName, false);
return RedirectToAction("HomePage", "Home");
}
ModelState.AddModelError("", "Login details are wrong.");
return View("MainLoginPage", user);
}
[HttpPost]
public ActionResult Register(UserInfo user)
{
if (ModelState.IsValid)
{
MembershipCreateStatus status;
Membership.CreateUser(user.UserName, user.Password, user.Email, null, null, true, out status);
switch (status)
{
case MembershipCreateStatus.Success:
{
return RedirectToAction("HomePage", "Home");
}
case MembershipCreateStatus.InvalidUserName:
{
ModelState.AddModelError(nameof(UserInfo.UserName), "Invalid username.");
break;
}
case MembershipCreateStatus.InvalidPassword:
{
ModelState.AddModelError(nameof(UserInfo.Password), "Invalid password.");
break;
}
case MembershipCreateStatus.InvalidEmail:
{
ModelState.AddModelError(nameof(UserInfo.Email), "Invalid email address.");
break;
}
case MembershipCreateStatus.DuplicateUserName:
{
ModelState.AddModelError(nameof(UserInfo.UserName), "Already registered.");
break;
}
case MembershipCreateStatus.DuplicateEmail:
{
ModelState.AddModelError(nameof(UserInfo.Email), "Already registered.");
break;
}
case MembershipCreateStatus.UserRejected:
{
ModelState.AddModelError("", "User rejected.");
break;
}
default:
{
ModelState.AddModelError("", "Unknown error.");
break;
}
}
}
return View("MainLoginPage");
}
}
NB: In this case, you'll also want to remove the GET versions of Login and Register , since you don't have separate views for them.
You also need to verify the status when registering a new user, using the MembershipCreateStatus enum.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I add this
return View("MainLoginPage", user);
line and it work fine in Login Form, but in registration form still I face problem Since both forms are in same view.
and when the page load, only Login form appear till I click on link go to register login form disappear and register form appear with some fade animation,,
now I add the line in Register
return View("MainLoginPage", user);
when already registered it return to login form and already register error appear there..
<div class="container">
<a class="hiddenanchor" id="toregister"></a>
<a class="hiddenanchor" id="tologin"></a>
<pre>
<div class="wrapper">
<div id="login" class="animate form">
@{ Html.RenderPartial("_Login"); }
</div>
<div id="register" class="animate form">
@{ Html.RenderPartial("_Register"); }
</div>
</div>
|
|
|
|
|
Then you'll need to add something to tell whatever script or CSS you're using to switch between the forms that the register form should be active instead of the login form.
Since you haven't shared that part of the code, I can't tell you how to do that.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
It switch between the forms probably, and successfully registered users. But the only problem in handling the Error like if user is exist it goes to login form instead and error appear there.
the animation is done in css
.wrapper p.change_link a {
display: inline-block;
font-weight: bold;
padding: 3px 6px;
color:#ffffff;
margin-left: 10px;
text-decoration: none;
-webkit-transition: all 0.4s linear;
-moz-transition: all 0.4s linear;
-o-transition: all 0.4s linear;
-ms-transition: all 0.4s linear;
transition: all 0.4s linear;
}
.change_link
{
font-weight:550;
margin-left: 30px;
color:#23C1B0;
font-family: "Trebuchet MS","Myriad Pro",Arial,sans-serif;
font-size:17px;
}
<h1>toregister:target ~ .wrapper #register,</h1>
<h1>tologin:target ~ .wrapper #login{</h1>
z-index: 22;
-webkit-animation-delay: .6s;
-webkit-animation-timing-function: ease-in;
-moz-animation-delay: .6s;
-moz-animation-timing-function: ease-in;
-o-animation-delay: .6s;
-o-animation-timing-function: ease-in;
-ms-animation-delay: .6s;
-ms-animation-timing-function: ease-in;
animation-delay: .6s;
animation-timing-function: ease-in;
-webkit-animation-name: scaleIn;
-moz-animation-name: scaleIn;
-ms-animation-name: scaleIn;
-o-animation-name: scaleIn;
animation-name: scaleIn;
}
#toregister:target ~ .wrapper #login,
<h1>tologin:target ~ .wrapper #register{</h1>
-webkit-animation-timing-function: ease-out;
-moz-animation-timing-function: ease-out;
-o-animation-timing-function: ease-out;
-ms-animation-timing-function: ease-out;
animation-timing-function: ease-out;
-webkit-animation-name: scaleOut;
-moz-animation-name: scaleOut;
-ms-animation-name: scaleOut;
-o-animation-name: scaleOut;
animation-name: scaleOut;
}
here is the place of change link
@using (Html.BeginForm("Register", "Account", FormMethod.Post))
{<br />
@Html.AntiForgeryToken()
@Html.ValidationSummary(true, "Registeration Failed, fields.");
<pre>
<label data-icon="u"> </label>
@Html.EditorFor(user => Model.UserName, new { htmlAttributes = new { @class = "form-control", placeholder = "username" } })
@Html.ValidationMessageFor(user => Model.UserName)
<label data-icon="e"> </label>
@Html.EditorFor(user => Model.Email, new { htmlAttributes = new { @class = "form-control", placeholder = "mymail@mail.com" } })
@Html.ValidationMessageFor(user => Model.Email)
<label data-icon="p"> </label>
@Html.EditorFor(user => Model.Password, new { htmlAttributes = new { @class = "form-control", placeholder = "password" } })
@Html.ValidationMessageFor(user => Model.Password)
<input type="submit" value="Sign Up">
<p class="change_link"> Already a member ?<a href="#tologin" class="to_register"> Log in </a></p</pre>
modified 6-Jul-17 14:09pm.
|
|
|
|
|
The simplest solution is probably to modify your form so that it includes the anchor in its action attribute:
@using (Html.BeginForm(null, null, null, FormMethod.Post, new { @action = Url.Action("Register", "Account") + "#toregister" })
{
...
}
(Based on this StackOverflow answer[^].)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
It work. It return to register but still not in a good way..
Can I control this with Script??
|
|
|
|
|
What does "not in a good way" mean?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I mean still need improvement. I hope that I can share my project with u if its it is possible.
|
|
|
|
|
If you can't explain the problem, then I don't see how we can help you.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
If you can't explain the problem to people, how the $*%^ are you going to explain to the computer what to do to fix it? The computer is FAR more picky about it.
|
|
|
|
|
Hi I am newbie programmer and learning how to code using ASP.Net MVC. I have a simple project for clinic management. Im having trouble how to start doing invoice or something on how to print something like a certificate, receipt or doctor's prescription. I have this idea where you print a page but I think it's not the best way or practice. Sorry for the lousy problem.
How can I achieve this in the best way?
|
|
|
|
|
On the "server side", you create the invoice / report using any tool that can output HTML, PDF, DOCX (and optionally CSV, XLS). This include .Net reporting components, SQL Server reporting services.
The user / client then typically "downloads" the "type" of document they want; with you optionally emailing the stuff (reminders; tracking notices; receipts).
An actual "print" button (usually only found on bank sites, etc) would involve client side code; e.g. Javascript. (Something I would leave last / choose to ignore ... ugh).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Hi,
I am calling SSIS package from a Console Application, it was working fine until I need to change my Laptop, after I changed it, it started giving me these errors:
Error loading from XML. No further detailed error information can be specified for this problem because no Events object was passed where detailed error information can be stored.
This problem is happening when I am loading the package using Application object
_Pkg = _app.LoadFromSqlServer(PkgLocation, TargetServer=""server name", User Name=String.Empty (because Windows Auth), Password=String.Empty (because Windows Auth), null);
And this was working fine up until I had new laptop, but there could be Softwares mismatch between two Laptops but I have make it working. Note: and these all Packages are upgraded from SSIS 2008 to Data tools 2012.
I needed to remov and add back the Microsoft.SqlServer.DTSRuntimeWrap.DLL and Microsoft.SqlServer.ManagedDTS.DLL both the dlls to my machine, I have added them from GAC and as well as from the local folder after copying it to test different times but didn't help me much, in both the cases it was not running, throwing me the same error.
The only difference I could think of is I was having the SQL Server 2008 Integration Services installed on my previous machine but in the new machine I installed later but the evaluation version as it is difficult for me to get permission from our IT to install the Software in my Company, could it be the problem?
I am very much disappointed because this was working and has stopped sudden and I need to fix this issue urgently as I need to make changes to this app.
Any help a good suggestion, a link or Code snippet any thing would be very helpful - thanks in advance my friends.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
-- modified 29-Jun-17 20:19pm.
|
|
|
|
|