Click here to Skip to main content
15,924,367 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionHow to convert a EMF file to Bitmap Pin
hawkgao012924-Jul-10 22:06
hawkgao012924-Jul-10 22:06 
AnswerRe: How to convert a EMF file to Bitmap Pin
Peace ON27-Jul-10 0:55
Peace ON27-Jul-10 0:55 
GeneralRe: How to convert a EMF file to Bitmap Pin
hawkgao012927-Jul-10 2:17
hawkgao012927-Jul-10 2:17 
GeneralRe: How to convert a EMF file to Bitmap Pin
Peace ON27-Jul-10 2:29
Peace ON27-Jul-10 2:29 
NewsAnne Kathrine Petteroe speak on Enterprise Rich Internet Applications with the Adobe Flash Platform Pin
shankarjain201023-Jul-10 0:50
shankarjain201023-Jul-10 0:50 
GeneralRe: Anne Kathrine Petteroe speak on Enterprise Rich Internet Applications with the Adobe Flash Platform Pin
Pete O'Hanlon23-Jul-10 1:52
mvePete O'Hanlon23-Jul-10 1:52 
GeneralRe: Anne Kathrine Petteroe speak on Enterprise Rich Internet Applications with the Adobe Flash Platform Pin
Peace ON23-Jul-10 19:15
Peace ON23-Jul-10 19:15 
QuestionHandling exception in a better way [modified] Pin
souvikd23-Jul-10 0:39
souvikd23-Jul-10 0:39 
I am using a stored procedure to insert data into two tables in sql 2008 server. Now while handling exception I am using exception code to check the exception and accordingly i am showing the error message to the user.Can u tell me a better option to do the same.



Public Sub rtrnQry(ByVal usrNm As String, ByVal psWd As String, ByVal fNm As String, _
ByVal lNm As String, ByVal empId As Integer, ByVal proNm As String, ByVal aDm As String, ByVal rowno As Integer)
Try

Using cn As New SqlConnection(sqlConnStr)
cn.Open()
Using cmd As New SqlCommand("InsrtLogin", cn)
With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.AddWithValue("@empid", empId)
.Parameters.AddWithValue("@username", usrNm)
.Parameters.AddWithValue("@password", psWd)
.Parameters.AddWithValue("@firstname", fNm)
.Parameters.AddWithValue("@lastname", lNm)
.Parameters.AddWithValue("@adminpri", aDm)
.Parameters.AddWithValue("@proName", proNm)
.ExecuteNonQuery()
End With
End Using
End Using

Catch ex As SqlException
If chkBox1_Crtusr.Checked Then
If ex.Number.Equals(2627) Then 'Exception code for Primary Key Violation
MsgBox("Duplicate Employee ID cannot be inserted. Violation of Primary Key " & _
"Constraint Occured. Enter an unique value.Please check row number : 1", MsgBoxStyle.Critical, "Error")
Else
MsgBox(ex.ToString)
End If
If ex.Number.Equals(208) Then
MsgBox("Invalid Table Name. Check the Sql String.", MsgBoxStyle.Critical, "Error")
End If

End If
If chkBox2_Crtusr.Checked Then
If ex.Number.Equals(2627) Then 'Exception code for Primary Key Violation
MsgBox("Duplicate Employee ID cannot be inserted. Violation of Primary Key " & _
"Constraint Occured. Enter an unique value.Please check row number : 2", MsgBoxStyle.Critical, "Error")
Else
MsgBox(ex.ToString)
End If
If ex.Number.Equals(208) Then
MsgBox("Invalid Table Name. Check the Sql String.", MsgBoxStyle.Critical, "Error")
End If

Now I am calling the above procedure


Private Sub btnSubmit_CrtMul_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit_CrtMul.Click
Dim cnt As Integer = 0

Try

If chkBox1_Crtusr.Checked Then
rtrnQry(txtUsrNm_1.Text, txtPswd_1.Text, txtFName_1.Text, txtLName_1.Text, txtEmpID_1.Text, cmbProNm1.SelectedItem, cmbAdmin1.SelectedItem, 1)
Dim sqlLogin As String = "Select * from login where user_name ='" & txtUsrNm_1.Text & "'"
Dim usrVerified As String = DataStore.ExecuteScalar(sqlLogin, sqlConnStr)
If usrVerified.Length > 0 Then
Call ClearData(1)
cnt = cnt + 1
End If
End If

If chkBox2_Crtusr.Checked Then
rtrnQry(txtUsrNm_2.Text, txtPswd_2.Text, txtFName_2.Text, txtLName_2.Text, txtEmpID_2.Text, cmbProNm2.SelectedItem, cmbAdmin2.SelectedItem, 2)
Dim sqlLogin As String = "Select * from login where user_name ='" & txtUsrNm_2.Text & "'"
Dim usrVerified As String = DataStore.ExecuteScalar(sqlLogin, sqlConnStr)
If usrVerified.Length > 0 Then
Call ClearData(2)
cnt = cnt + 1
End If
End If

If chkBox3_Crtusr.Checked Then
rtrnQry(txtUsrNm_3.Text, txtPswd_3.Text, txtFName_3.Text, txtLName_3.Text, txtEmpID_3.Text, cmbProNm3.SelectedItem, cmbAdmin3.SelectedItem, 3)
Dim sqlLogin As String = "Select * from login where user_name ='" & txtUsrNm_3.Text & "'"
Dim usrVerified As String = DataStore.ExecuteScalar(sqlLogin, sqlConnStr)
If usrVerified.Length > 0 Then
Call ClearData(3)
cnt = cnt + 1
End If
End If


Now when I am doing this, for each exception the error message is appearing twice, I need to take care of that as well. Please Help, Thanks in advance

modified on Friday, July 23, 2010 8:57 AM

AnswerRe: Handling exception in a better way Pin
R. Giskard Reventlov23-Jul-10 2:30
R. Giskard Reventlov23-Jul-10 2:30 
AnswerRe: Handling exception in a better way Pin
Luc Pattyn23-Jul-10 2:56
sitebuilderLuc Pattyn23-Jul-10 2:56 
QuestionMessage Removed Pin
21-Jul-10 21:21
sr15921-Jul-10 21:21 
AnswerRe: problem in creating organisation chart from Mysql database using C#, ASP.net [Repost] Pin
Richard MacCutchan21-Jul-10 21:34
mveRichard MacCutchan21-Jul-10 21:34 
QuestionUnable to use array for control Pin
souvikd21-Jul-10 10:07
souvikd21-Jul-10 10:07 
AnswerRe: Unable to use array for control Pin
Abhinav S21-Jul-10 18:41
Abhinav S21-Jul-10 18:41 
AnswerRe: Unable to use array for control Pin
Roger Wright21-Jul-10 19:45
professionalRoger Wright21-Jul-10 19:45 
AnswerRe: Unable to use array for control Pin
Goutam Patra21-Jul-10 22:20
professionalGoutam Patra21-Jul-10 22:20 
GeneralRe: Unable to use array for control Pin
souvikd21-Jul-10 23:18
souvikd21-Jul-10 23:18 
GeneralRe: Unable to use array for control Pin
Goutam Patra21-Jul-10 23:38
professionalGoutam Patra21-Jul-10 23:38 
GeneralRe: Unable to use array for control Pin
souvikd22-Jul-10 0:45
souvikd22-Jul-10 0:45 
GeneralRe: Unable to use array for control Pin
Goutam Patra22-Jul-10 1:21
professionalGoutam Patra22-Jul-10 1:21 
GeneralRe: Unable to use array for control Pin
souvikd22-Jul-10 18:25
souvikd22-Jul-10 18:25 
AnswerRe: Unable to use array for control Pin
gargagan26-Jul-10 5:57
gargagan26-Jul-10 5:57 
QuestionClickOnce InvalidDeploymentException Pin
agent00zelda21-Jul-10 7:59
agent00zelda21-Jul-10 7:59 
AnswerRe: ClickOnce InvalidDeploymentException Pin
Peace ON22-Jul-10 20:27
Peace ON22-Jul-10 20:27 
QuestionGridview values not save on postback Pin
Clint Westwood21-Jul-10 5:20
Clint Westwood21-Jul-10 5:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.