|
Yes, I can imagine it will avoid headaches in the future.
There seems to be an abundance of articles here:
http://www.codeproject.com/search.aspx?q=life+cycle&x=7&y=6&sbo=kw[^]
so I have made a note to try to come to terms with the basic concepts over the next few days.
I am grateful that you have stressed it's importance. I suppose it's like learning any human language: we put basic building blocks - grammar, vocabulary, etc - in place to construct the skeleton of the language and only afterwards do we add flesh to it.
Thanks again, jkirkerx
|
|
|
|
|
Hello:
i am using this kind of code for connection to the data base.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Configuration;
namespace Kiu_webS
{
public class Connections
{
SqlConnection _connection;
private string connStr = "";
public Connections()
{
connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
}
public Connections(string conStr)
{
this.connStr = conStr;
}
public string connectionString
{
get { return connStr; }
set { connStr = value; }
}
public SqlConnection GetDBConnection()
{
_connection = new SqlConnection(connStr);
return _connection;
}
public void connectDB()
{
try
{
_connection.Open();
}
catch
{
throw;
}
}
public void DisconnectDB()
{
try
{
_connection.Close();
}
catch
{
throw;
}
}
}
}
as i insert data from form to database i am getting this error. The coonection String property has not been initialized.
web.config file
<configuration>
<connectionStrings>
<add name="ConnStr" connectionString="Data Source = inayat; Initial Catalog = KIU; User ID=sa; Password=jan5562"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<authentication mode="Forms">
<forms name="KIUAuth" loginUrl="login.aspx" protection="All" path="KIUAuth/" timeout="30" slidingExpiration="true"/>
</authentication>
</system.web>
</configuration>
|
|
|
|
|
public class Connections
{
SqlConnection _connection;
private string connStr = "";
public string connectionString
{
get { return connStr; }
set { connStr = value; }
}
public Connections()
{
connStr = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectinString"].ConnectionString;
}
public Connections(string conStr)
{
this.connStr = conStr;
}
public SqlConnection GetDBConnection()
{
_connection = new SqlConnection(connStr);
return _connection;
}
public void connectDB()
{
try
{
_connection.Open();
}
catch
{
throw;
}
}
public void DisconnectDB()
{
try
{
_connection.Close();
}
catch
{
throw;
}
}
}
In Web.config
<add name="ConnectinString" connectionString="Data Source=inayat;Initial Catalog=KIU; User ID=sa; Password=jan5562" providerName="System.Data.SqlClient" />
Works fine for me.
|
|
|
|
|
I need to be able to figure out something very difficult. I have to create an MVC controller that will display the "User Profile" View (shows user information) when the "Display User Profile" View's ActionLink Is selected. Now, the user is an Active Directory user who has a user profile database entery created when loging into the application. The user profile data contains a profile data ID stored in Entity Framework. How would you recommend I access the user from the Entity Framework model? I know I should use the Entity Framework user profile ID when doing the controller search but don't know how to how to access it and how to find the user record for the actual search? Any help would be great.
Thanks,
Steve Holdorf
modified 22-Jun-14 4:17am.
|
|
|
|
|
I need to be able to figure out something very difficult. How do I create a parent Controller that dynamically hides and shows partial View's UI controls after the parent View's ActionLink controller is called? My example is I have a user roles model and based on the user's role when selecting the main View's ActionLink only certian UI controls are to be dynamically displayed in both the parent View and it's partial Views. Any help would be great.
Thanks,
Steve Holdorf
modified 21-Jun-14 18:33pm.
|
|
|
|
|
A project gets built fine from Visual Studio without a problem from developers work station. Now we need to move it to DEV and UAT server. I've been struggling all day trying to get my ASP.NET project built with msbuild on a server with no Visual Studio installed (dev tools not permitted on servers) -
The type or namespace name 'Optimization' does not exist in the namespace 'System.Web'
The type or namespace name 'DotNetOpenAuth' could not be found
Couple attempts were made:
1. Install Windows SDK (http://msdn.microsoft.com/en-US/windows/hardware/hh852363) - appears there has been a lot of discussions from another Stackoverflow post (Couple relevant posts from Stackoverflow did not help[^]). You'd also need to add to environment variables PATH
C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools
(This did NOT help)
2: gacutil to install the dll's? (no vs command prompt - as said, no dev tool/Visual Studio permitted on server)
3: copy the dlls' to (i.e. same folder as MSBuild.exe):
C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\
(This did NOT help)
4: Copy local = true
(This did NOT help - the dll's apparent msbuild can't find already in bin folder of the ASP.NET application)
It appears to be a bug with msbuild - http://social.msdn.microsoft.com/Forums/vstudio/en-US/434abf1a-30db-4b13-8062-13755898dd71/msbuild-is-unable-to-link-to-a-webapplication-project?forum=msbuild
Anyone has experience with this? Thanks
dev
modified 20-Jun-14 18:14pm.
|
|
|
|
|
I want to store the values of a Gridview selected row in sessions through a button field in the gridview but
its giving me a "Index out of range " error at
GridViewRow row = AdminSearchGridView.Rows[index]
Note: There is only one row in the gridview currently from which I want to select the values I want.
I checked that the e.CommandArgument is returning a int value 0 but
i cannot figure out what is going wrong since AdminSearchGridView.Rows[0] makes sense as there is a row in the gridview
then why Index out of range.?
Here is my code for Gridview...
<asp:GridView ID="AdminSearchGridView" runat="server" AutoGenerateColumns="False"
Style="color: #333333; border-collapse: collapse; font-size: 14px;
text-align: center;width: 1530px; margin-left: 0px; margin-top: 0px" CellPadding="4" ForeColor="#333333"
AutoGenerateDeleteButton="True" DataKeyNames="ID" OnRowDeleting="AdminSearchGridView_RowDeleting"
OnRowCommand="AdminSearchGridView_RowCommand">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:ButtonField ButtonType="Button" Text="Issue" CommandName="Issue" />
<asp:BoundField DataField="IssueStatus" HeaderText="Issue Status" />
<asp:BoundField DataField="AccessionNo" HeaderText="Accession Number" />
<asp:BoundField DataField="CallNo" HeaderText="Call Number" />
<asp:BoundField DataField="Title" HeaderText="Title" />
</Columns>
</asp:GridView>
Here is Code Behind...
protected void AdminSearchGridView_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Issue")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = AdminSearchGridView.Rows[index];
string accessno = AdminSearchGridView.Rows[index].Cells[3].Text;
string title = AdminSearchGridView.Rows[index].Cells[5].Text;
Session["accessno"] = accessno;
Session["title"] = title;
}
}
|
|
|
|
|
The error suggests there are no rows in AdminSearchGridView at the time you call your code. Can you confirm it with debugger while running your code? The fact it is displayed on page doesn't mean it is available later
If it is the case then you can check the following:
- Make sure ViewState is enabled on your page.
- if you bind data to AdminSearchGridView in Page_Load() make sure it is no rebound on postback:
if (!IsPostBack) { }
--
"My software never has bugs. It just develops random features."
|
|
|
|
|
Hai All,
Could anyone please tell me how to configure Local SMTP server and how to send mail through C# code.
Regards,
Rajesh KAndepu
|
|
|
|
|
There are lots of samples here on CodeProject: Google will find them for you.
|
|
|
|
|
I am getting "Failure sending mail" and it said Socketexception unable to connect.
I am using windows8 and visual studio 2010. And I have ran the web application from visual studio. Should i do anything else ..
Below is my code..
<pre lang="c#">
string from = "no-reply@retro.com";
string to = "rajeshvec2006@gmail.com";
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
mail.To.Add(to);
mail.From = new System.Net.Mail.MailAddress(from, "test", System.Text.Encoding.UTF8);
mail.Subject = "test";
mail.SubjectEncoding = System.Text.Encoding.UTF8;
mail.Body = "hai";
mail.BodyEncoding = System.Text.Encoding.UTF8;
SmtpClient client = new SmtpClient();
client.Host = "Localhost";
client.Send(mail);
</pre>
Could you please help me in this..
|
|
|
|
|
SmtpClient client = new SmtpClient();
client.Host = "Localhost";
Do you have a SMTP server running on your local PC? Without it this will not work.
|
|
|
|
|
I have configured SMTP mail in IIS server 7.0. IS that enough or I have to install anything explicitly. Don't mind I am asking you minute details because this is the first time I am handling this SMTP servers.
Regards,
Rajesh
|
|
|
|
|
OK, but that does not answer my question.
|
|
|
|
|
Let me explain about my senario.....
I have a windows7 machine and IIS installed on it....I have hosted a ASP.Net website in it.. I have to send email notifications from the registered users on my website...I do not want to use gmail or any other smtp server...I have to send the mails from the site with some random mailid like noreply@something.com....How can I achieve it....
|
|
|
|
|
You still have not answered the question, "do you have an SMTP server running on 'localhost'.".
|
|
|
|
|
NO i do not have a smtp server running.. I want help about this...
|
|
|
|
|
Then you cannot send an email to that port. Google for " free SMTP" to find one.that you can use.
|
|
|
|
|
Can you suggest me any open source smtp servers..
|
|
|
|
|
|
http://www.systemnetmail.com/[^] is a good place to start.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I am getting "Failure sending mail" and it said Socketexception unable to connect.
I am using windows8 and visual studio 2010. And I have ran the web application from visual studio. Should i do anything else ..
Below is my code..
<pre lang="c#">
string from = "no-reply@retro.com";
string to = "rajeshvec2006@gmail.com";
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
mail.To.Add(to);
mail.From = new System.Net.Mail.MailAddress(from, "test", System.Text.Encoding.UTF8);
mail.Subject = "test";
mail.SubjectEncoding = System.Text.Encoding.UTF8;
mail.Body = "hai";
mail.BodyEncoding = System.Text.Encoding.UTF8;
SmtpClient client = new SmtpClient();
client.Host = "Localhost";
client.Send(mail);
</pre>
Could you please help me in this..
|
|
|
|
|
I see that the SMTP client is not configured properly. I had a very similar problem while try to send an email from my C# application.
I resolved that by configuring the SMTP client correctly. Please make sure you set all the necessary SMTP client properties, like,
- Host
- Port
- UseDefaultCredentials
- EnableSsl
- ServicePoint
Check your credentials(if you are not using the Default credentials)
|
|
|
|
|
The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
I am running this application in my local machine. So no heavy DB queries and all. I have pasted my code below. This error happens on con.Open()
string connString = ConfigurationManager.ConnectionStrings["DL"].ConnectionString;
using (SqlConnection con = new SqlConnection(connString))
{
SqlCommand cmd = new SqlCommand("spGetAllEmployees", con);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
Employee employee = new Employee();
employee.ID = Convert.ToInt32(rdr["ID"]);
employee.Name = rdr["name"].ToString();
employee.Gender = rdr["gender"].ToString();
employee.City = rdr["city"].ToString();
employee.DateOfBirth = Convert.ToDateTime(rdr["dateofbirth"]);
Employees.Add(employee);
}
}
Help me to resolve pls.
Thanks, Geetha
|
|
|
|
|