|
hi
I have this webpage called register.aspx. user has a form of 4 fields and completes them to get an activation email and ... .
Where I want to optimize my code is a place where I want to use a try & catch block where if user enters an existing username he will divert to catch block that tells him to reconsider about his/her username. I mean I want to stop username duplication, what kind of exeption or sql query do I need to use? Please inform me with details since I am kind of new
Thanks
Proper Prepration Prevents Poor Performance! h
|
|
|
|
|
You can put a primary key or unique constraint on the user name column and then, when the SqlException gets thrown because of violation of the constraint, you can display the error message to the user.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
hi there, for sure this solution is the best but please tell me how should I do this.
I have my primary key on ID field but how can I put unique constraint on a field?
and what is the code to to get the thrown sqlexception? please give me coding way too.
Proper Prepration Prevents Poor Performance! h
|
|
|
|
|
A primary key, by definition, has a unique constraint on the column.
The code should look something like this:
try
{
... try to insert new record ...
}
catch(SqlException se)
{
... set error message to something appropriate ...
} If you go to Google and search on "asp.net simple login page," you'll be amazed at the number of different samples for different databases that exist on the Internet. I don't feel like reproducing that here.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Instead of relying on exceptions to catch the error, you should just do a database connection yourself selecting the user with the supplied username, if a row is returned, then that username exists. Following code is in VB.NET
Dim strQuery as string = ""
strQuery should be where you select * from users where username = username you're trying to test
Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("mainDBConnection").ConnectionString)
conn.Open()
Dim cmd As New SqlCommand(conn.Database & ".dbo." & strQuery, conn)
Dim dr As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
if dr.HasRows = true then
'DISPLAY ERROR MSG
end if
Obviously you'll have to change around specifics like database connection string etc. Hope this helps.
|
|
|
|
|
Can any tell me free plagiarism software to integrate in asp.net
|
|
|
|
|
Hello,
Im building a news page. The data is stored in an access db. Im using a datalist control to retrieve newsid and title. Ive wrapped a navigateurl control around the title using the newsid and am posting the page back to itself. This works fine. On the same form I have another datasource control to select the newsid and news detail.
I want to display the news detail on the same page when a user clicks on the title in the datalist. Other than a detailsview control is it possible to display the data in some other way ?
Many thanks for your help.
Bruce.
|
|
|
|
|
Hi friends i m looking coding for dynmaic controls. how to acess the value from a dynamic text box . if we r creating some text boxes at run times then how will we retain thr value when page unload or postback .
Thanks
Jasjit
|
|
|
|
|
You may use FindControl() method to search for controls in a container control(Page, Panel, etc..)
So, for example to search for a TextBox control which is contained in a Panel , you have to call panel.FindControl("textBox1") and make a cast from Control to TextBox .
Calin
|
|
|
|
|
please i am trying to build a progam that will generate barcodes, stores the original characters in a database and prints the barcode image on a ticket.
the same program should be able to read the barcodes on the ticket and match them with original character stored in the database thereby giving or denying access to the carrier if the validation was successful or not. i need help.
i would like to get source codes and i am not limiting the option to only ASP.NET. i can handle java and php too.
urgently waiting.
|
|
|
|
|
Have you started to implement the program? On what sections do you need help?
You are waiting to get the program done?
Calin
|
|
|
|
|
hi,
please can some one give me an example of how xslt /xsl is used in dotnet.<
swetha
|
|
|
|
|
Here[^].
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hi,
How can I sort nodes in a TreeView Control
Best wishes
|
|
|
|
|
Sorting in the TreeView is a manual process. You need to implement it yourself. Here's a link[^] to get you started.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hi
I am developing a web application in ASP.Net 2.0
I have a web page for project registration in which I can add project details like Project code, name description,start date, end date etc. I want to include in this page the project members and roles.
I have added a table with 2 columns which contains combo boxes bounded to Project member table and roles table. Also a button to add new member. On click of the add button i create new row to the table with combo box controls bounded to project members and roles. But I cannot retrieve the selected values of the dynamically added controls.
Can any one please help me to solve this.
With kind regards,
Jimi
|
|
|
|
|
when i was trying to move from loginpage to some another aspx page like adminindex.aspx page it is redirecting to the same login page. i used response.redirect as well as server.transfer in login button click event of loginpage
|
|
|
|
|
send me the code.
Regards
Keyur Satyadev
|
|
|
|
|
hi
i developed a web application
now i need to convert it into intranet application
which can run in only company environment only
thanks in advance
lavan kumar
|
|
|
|
|
There is no question here. I am going to assume your question is "How do I do that?"
You don't need to do anything that I can see other than install the application in the company that is going to use it. Is there anything you think you ought to be doing?
|
|
|
|
|
Nopthing . u have to host your site on a particular system . and all other system use this Application by writing url of the pages with that system ipaddress.
suppose u host ur site in 172.0.0.12
then others can use this application by writing http://172.0.0.12/projectname/page.aspx
|
|
|
|
|
Dear Experts,
I want decrypt the string in .Net which is encrypt by the java using AES algorithm. If i use RijndaelManaged
class its showing following error.
Padding is invalid and cannot be removed.
and the i give the .net decrypt code as follows as
private void Decrypt()
{
string strEncrypt = "2f8ae3760636f348e0cb711c5109b78f";// Encrypt string by Java
Rijndael rjin = Rijndael.Create();
rjin.KeySize = 128;
string key = "22tqlER6RPmVvA2omvJJxg=="; // Autokey generated by Java
char[] input = key.ToCharArray();
Base64Decoder decoder = new Base64Decoder(input);
byte[] lByte = decoder.GetDecoded();
rjin.Key = lByte;
rjin.Mode = CipherMode.CBC;
rjin.Padding = PaddingMode.ANSIX923;
ICryptoTransform crypt = rjin.CreateDecryptor();
byte[] cipher = FromHex(strEncrypt);
byte[] plain = crypt.TransformFinalBlock(cipher, 0, cipher.Length); // Here Error showing
Response.Write("Decryped string : " + System.Text.Encoding.UTF8.GetString(plain) + "");
}
Anybody have idea give me
i would be appreciate some help.
Regards
Mani
|
|
|
|
|
Hi there, please help if you can, i am kind of new around so please be patient with me if my question is kind of stupid for you.
I am developing a payroll system that will take the time user is logged in and out subtract them and saves the amount of hours worked in a database table in a column called time_worked. Now these values are stored in the DB as String with the following format (HH:MM:SS).
I want to get these values in an arraylist and add them together.
Right now I am doing the following but it ain't working:
Stored Procedure Used:
@username varchar(50),
@dateStart varchar(50),
@dateFinish varchar(50)
AS
SELECT time_worked
FROM tblTimeWorked
WHERE (user_username = @username) AND (date BETWEEN @dateStart AND @dateFinish)
private void DoTimeWorked()
{
try
{
string start = txtFromDate.Text;
string end = txtToDate.Text;
userService.SupportDS.tblUsersRow rw = (userService.SupportDS.tblUsersRow)userWebservice.GetUsersByUsername(grdUsersPay.SelectedDataKey.Value.ToString()).Rows[0];
string user = rw.user_username;
int hours = 0;
int min = 0;
int sec = 0;
string worked = "";
ArrayList myArrayList = new ArrayList();
DateTime dayViewed = Convert.ToDateTime(start);
foreach (DataRow row in userWebservice.GetHoursWorked(user, start,end).Rows)
{
myArrayList.Add(row);
dayViewed = dayViewed.AddDays(1);
start = dayViewed.ToShortDateString();
}
}
catch (Exception ex)
{
throw ex;
}
}
Question 2: Is there a way how you can make an addition of time? (when minute is 60 adds 1 to hour and resets to 00 minutes etc...)
|
|
|
|
|
Try this . let suppose that u have to time in database
string t1 = "10:00:00" string t2="17:30:50" sometime problem in timespan function so u store time in string
now apply splict function i both strings so that u can find h1 ,h2 , m1,m2 ,c1,c2
now ssolve them ..
in grid in ther is 3 col
ti , te , diff
then use
for (int i =0; i<grid.rows.count;i++)>
{
string t1 = (label)(grid.findcontrl("colname").tostring());
string t2 = (label)(grid.findcontrl("colname").tostring());
string diff = (label)(grid.findcontrl("colname").tostring());
here find find h1 ,h2 , m1,m2 ,c1,c2
}
this is just a logic
|
|
|
|
|