TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Loeurt
NA
5
11.5k
Try Cath , throw Error
Jun 25 2009 12:38 AM
Please our member help me...(SQL server 2005 ,and C# language)
I want to check duplicate Id in tblStaffDetail before insert data to this table ..
so i write this methord:
public bool IsexistID(String IsID, StaffDetailInfo objInfo, SqlTransaction sqlTran)
{
bool blresutl = false;
String StrSQL = "SELECT StName FROM TblStaffDetail \r\n" +
"WHERE StID=@StID";
try
{
SqlCommand sqlCom = DBHelper.SQL_CONNECTION.CreateCommand();
sqlCom.CommandText = StrSQL;
sqlCom.Transaction = sqlTran;
CommandHelper(sqlCom, objInfo);//Make Object from other Methord
GetStaffName = sqlCom.ExecuteScalar().ToString();
}
catch (Exception ex)
{
ex.ToString()
}
if (GetStaffName == null)
{
blresutl = false;
}
else
{
blresutl = true;
}
return blresutl;
}
this methord is working if the ID is really duplicated , but if ID is not Exist it will catch error , and i can't insert new record ..
I want to kill this catch error ..and not catch if input new data .Please help me
Reply
Answers (
1
)
How to execute .jar file in c#
Write get and set method for database with table column names are not fixed