|
hello friends i am fresher i need real time example for using oops in asp.net with C# application..give me some code..
|
|
|
|
|
|
Start with some good samples on msdn.
You can also pick up a good book and read.
|
|
|
|
|
|
|
Try DotnetFunda, Questpond. The second one requires a payment for their training and dvd's. But the amount is very nominal and worth it.
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
You can for example enter the length and width of the web (VS.NET2005), when it runs out of range index error exception was unhandled by user code for chieudai
public class Tinh
{
private Int32 _quanhuyen;
private String _diachiNha;
private Double _chieudai;
private Double _chieurong;
private Double _dientichDat;
}
public Int32 Quanhuyen
{
get { return _quanhuyen; }
set { _quanhuyen = value; }
}
public String DiachiNha
{
get { return _diachiNha; }
set { _diachiNha = value; }
}
public Double Chieudai
{
get { return _chieudai; }
set { _chieudai = value; }
}
public Double Chieurong
{
get { return _chieurong; }
set { _chieurong = value; }
}
public Double DientichDat
{
get { return _dientichDat; }
set { _dientichDat = value; }
}
private Tinh DienTich(IDataReader dr, bool GetTotalRecords)
{
Tinh obj = new Tinh();
...
obj.Quanhuyen = (dr["Quanhuyen"] is DBNull) ? Int32.MinValue : (Int32)dr["Quanhuyen"];
obj.DiachiNha = (dr["DiachiNha"] is DBNull) ? String.Empty : (String)dr["DiachiNha"];
// bottom line this error index out of range exception was unhandled by user code
obj.Chieudai = (dr["Chieudai"] is DBNull) ? Double.MinValue : (Double)dr["Chieudai"];
obj.Chieurong = (dr["Chieurong"] is DBNull) ? Double.MinValue : (Double)dr["Chieurong"];
obj.DientichDat = (dr["DientichDat"] is DBNull) ? Double.MinValue : (Double)dr["DientichDat"];
if (GetTotalRecords)
obj.TotalRecords = (dr["TotalRecords"] is DBNull) ? -1 : Globals.ConvertToInt32(dr["TotalRecords"]);
return obj;
}
error index out of range exception was unhandled by user code
modified 11-Jul-12 3:04am.
|
|
|
|
|
On which line you are getting this error ?
|
|
|
|
|
Your coding skills look pretty advanced, I don't see why you can't figure it out yourself.
Why is chieudai a double and not a Int32?, you would think all the obj have the same value, since it's a list of people. I don't understand chieudai, is it a lemon, lime, orange, or cherry.
Did you assign the property chieudai a default value, if the property is not set in the web form.
|
|
|
|
|
I fixed all right, thank you for comments
|
|
|
|
|
hi i have a doubt about expire validation of user i make some thing. i am not sure about this .
Below code the all loop are not working.
String edate = session["edate"].ToString();
String today = DateTime.Now.ToString("d");
int result = edate.CompareTo(today);
if (result == 0)
{
Response.Write( "your account expire on today ");
}
else if (result < 0)
{
Response.Write("your account exipired ");
}
else
{
Response.Write("your account expire on next week ");
}
can anyone help
thanks
|
|
|
|
|
Try this code, I have skipped some validations and null checks so you can put them in place if it works.
String edate = session["edate"] as string;
DateTime convertedDate = DateTime.Parse(edate);
if (convertedDate == DateTime.Today)
{
Response.Write( "your account expire on today ");
}
else if (convertedDate > DateTime.Today)
{
Response.Write("your account exipired ");
}
else
{
Response.Write("your account expire on next week ");
}
Every now and then say, "What the Elephant." "What the Elephant" gives you freedom. Freedom brings opportunity. Opportunity makes your future.
|
|
|
|
|
I have the following questions about a linq to sql connection in a C# 2010 web
form application when comparing the *.dbml file to the web.config file:
The questions refer to the code listed below:
1. The top of the *.dbml file and the web.config file, there are refernces to
"TST_DEV" and "TST_DEV2". Can this discrepancy cause problems in the web form
application? If so, can you tell me how? I am asking this question since most
references in the production application refer to "TST_DEV" or "TST_DEV2" in the
same .dbml file and do not mix the references.
2. I do not understand what the
'name="Dmport.Properties.Settings.DBConnectionString" can be referring to. Can
you tell me what it is referring to?
3. Are the refernces to "DBConnectionString" in the .dbml file and web.config
file all related to each other? If so, would you tell me how all these items are
related to each other? If not, can you tell me what each "DBConnectionString" is
referring to?
top of .dbml file
<?xml version="1.0" encoding="utf-8"?><Database Name="TST_DEV"
Class="HisDataContext" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">
<Connection Mode="WebSettings" ConnectionString="Data
Source=SP9\MSSQL2008;Initial Catalog=TST_DEV2;Persist Security Info=True;User
ID=xx" SettingsObjectName="System.Configuration.ConfigurationManager.ConnectionS
trings"
SettingsPropertyName="DBConnectionString" Provider="System.Data.SqlClient" />
applicable web.config file
<add name="DBConnectionString" connectionString="Data Source=sqldev;Initial
Catalog=Tst_DV;Persist Security Info=True;User ID=R2;Password=A"
providerName="System.Data.SqlClient" />
<add name="Dmport.Properties.Settings.DBConnectionString"
connectionString="Data Source=sqldev;Initial Catalog=Tst_DV;Persist Security
Info=True;User ID=R2;Password=A" providerName="System.Data.SqlClient" />
<add name="TST_DEVConnectionString" connectionString="Data
Source=sqldev;Initial Catalog=Tst_DV;Persist Security Info=True;User
ID=R2;Password=A" providerName="System.Data.SqlClient" />
<add name="TST_DEV2ConnectionString" connectionString="Data
Source=sqldev;Initial Catalog=Tst_DV;Persist Security Info=True;User
ID=R2;Password=A" providerName="System.Data.SqlClient" />
|
|
|
|
|
Hi,
I have an asp.net application in which I want to retreive the data from an uploaded excel file.
I am doing everything good but dates are not getting formatted properly. Is there any way to findout the Date1904 value for the uploaded excel file in ASP.Net application.
Any code snippet or link would help a lot.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
Hello All
I am new to MVC3 and i need some help in understanding a issue.
I am using buttons on a page the button in question is a ADD Button. what i want to achieve is when user click button (Add create new) i want to return page (blank page) for user input for creating a new customer? In the call would i use a GET or POST method from the controller?
An example would really be appreciated
Regards
Kurt
|
|
|
|
|
Hi,
I explain my requirement with example.
Suppose GridView bind with 10 records. In each row in gridview have checkbox.Suppose i selected five record (i checked five checkbox).I need to update selected five records in database.
When I update first record I need to show updated Record in other gridview. same way when other record update i need to show updated record in other gridview.
it's urgent.please let me how to do it.
Note:-Update button is outside of gridview.
Thanks
Asif
.
modified 10-Jul-12 4:21am.
|
|
|
|
|
|
I am basically trying to step through my code for a C# 2010 web application and I can not see the value of my variables in most cases since the application is 'optimized'. Since I want to be able to see the values in variables whwn I step through the code, I will let you know what I have done to solve my problem and you might be able to tell me how to fix this problem:
1. I rebuild from the file menu.
2. I selected the configuation option to be 'debug',
3. for the project file that is the web app, I made certain the optimize was not checked.
4. When I went to windows--> debug--> modules I saw the following:
a. my specific dlls were recently compile, and they are optimized.
b. I find some microsoft dlls saying, "Cannot find or open the PDB file."
Thus can you suggest what I can to make certain my modules are not optimized so I can step through the code?
|
|
|
|
|
In your project properties, at the Build tab, there is an Advanced... button at the bottom right corner (Output section).
Click it and check the value of the Debug Info option. If it's not, try setting it to full and see if that helps.
2A
|
|
|
|
|
This option was already set on.
|
|
|
|
|
Check your web.config file, if it includes the compilation.debug option and it's set to true :
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
</configuration>
Also, see if the Suppress JIT optimization on module load option is not unchecked. (It's found under Options->Debugging->General).
What exactly happens when you add a breakpoint and run your app?
2A
|
|
|
|
|
Until two weeks ago I could not even step through the code. I changed a debugging option to just be able to see my code.
I will check inot what you suggested.
basically what happens are the variables are optimized and that is why I can not see their values.
In all the project files, I have the 'optimized' option unchecked.
|
|
|
|
|
I am asking this question since I would like to know what is the best method of coding in a C # 2010 web form page that I just wrote. I read somewhere that everytime you need a datacontext object, you should
create it. There was no reference also to removing the datacontext object.
Thus on the current web form page that I am using that connects to a sql server 2008 r2 database, I am doing the following:
1. I never remove the AttDataContext from memory.
2. On the same web page, I am referring to the same linq to sql *.dbml file. However depending upon what I user clicks on, I have the following 3 datacontext objects:
a. AttDataContext,
b. Att2DataContext,
c. Att3DataContext.
Can you tell me if the above if a good idea or not? If not, can you tell me how I should use the same data context object on the same web form page?
|
|
|
|
|
Implement the using pattern when invoking these objects:
using (AttDataContext db = new AttDataContext())
{
}
This construct will close and dispose for you. You should not maintain an active connection where it is not required.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
Hello.
Is it possible to achive this:
(all is inside web.config)
<configuration>
<appSettings>
<add key="strSQLServer" value="srvproduction\SQL2008Express">
</appSettings>
<connectionStrings>
<add name="dbConn" connectionString="Data Source=" + key["strSQLServer"] + ";MultipleActiveResultSets=True;Initial Catalog=db1;Persist Security Info=True;Connection Timeout=600;User ID=sa;Password=***" providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>
Like I said at the begining: all is inside web.config
??
|
|
|
|