vadder85 Posted March 9, 2006 Share Posted March 9, 2006 Hello..hope someone can help me..I want to make an error checking that can give output "Error" if there are no data in sv_no...Below are my asp code: staffnumber=Session("staffno") set conn = server.CreateObject ("ADODB.Connection") conn.Open GetConnectString sql="select supervisor_no as sv_no "&_ "from staff "&_ "where staff_no='" & staffnumber & "'" Set rs=conn.Execute(sql)-------------------------------------------------------------------------------------------- if rs.EOF then <script language="JavaScript" type="text/JavaScript"> window.alert("Error") </script> end if--------------------------------------------------------------------------------------------tq...may god bless u Link to comment Share on other sites More sharing options...
Siddhesh Posted March 9, 2006 Share Posted March 9, 2006 Hello..hope someone can help me..I want to make an error checking that can give output "Error" if there are no data in sv_no...Below are my asp code:<{POST_SNAPBACK}> So what is the problem??Is this code not working or you are gettting some another error??the code is looking fineu can also use as if rs.EOF then Response.write "Error" Response.End end if Link to comment Share on other sites More sharing options...
vadder85 Posted March 9, 2006 Author Share Posted March 9, 2006 Set rs=conn.Execute(sql)-------------------------------------------------------------------------------------------- if rs.EOF then <script language="JavaScript" type="text/JavaScript"> window.alert("Error") </script> end if--------------------------------------------------------------------------------------------<{POST_SNAPBACK}> the problem is some "staff_no" may don't have "supervisor_no"...so, how could i display an Error message to the user if the data in "supervisor_no" is empty..is it enough by just using rs.EOF ?or asp have other way? Link to comment Share on other sites More sharing options...
Siddhesh Posted March 9, 2006 Share Posted March 9, 2006 the problem is some "staff_no" may don't have "supervisor_no"...so, how could i display an Error message to the user if the data in "supervisor_no" is empty..is it enough by just using rs.EOF ?or asp have other way?<{POST_SNAPBACK}> As you mentioned one way is using rs.EOFthe other way is by using recordcounti.e.if rs.RecordCount = 0 Then Response.Write " No Record Present" End If Link to comment Share on other sites More sharing options...
vadder85 Posted March 9, 2006 Author Share Posted March 9, 2006 staffnumber=Session("staffno") set conn = server.CreateObject ("ADODB.Connection") conn.Open GetConnectString sql="select supervisor_no as sv_no "&_ "from staff "&_ "where staff_no='" & staffnumber & "'" Set rs=conn.Execute(sql)-------------------------------------------------------------------------------------------- if rs.EOF then <script language="JavaScript" type="text/JavaScript"> window.alert("Error") </script> end if--------------------------------------------------------------------------------------------<{POST_SNAPBACK}> i have made one code regarding this problem...please help by correcting this code..this actually what i want..but i'm not sure whether the coding is correct or notcheck this.. <% if ("supervisor_no"=is null) then response.write("Error") end if %>all solution form our friend is actually not what i mean..what i mean here is actually in table staff there are other column too..so by giving rs.EOF it will check all the column and data...that is what i did not neednow what i need is that the" if statement" will only check supervisor_no column whether the data is empty or not..if yes,just display error message..that's all i want...this is because,in the supervisor_no column, there are some empty data as the user will be notify by error message to update their supervisor no if the data is empty..i hope everybody can understand..sorry for the bad language..tq... Link to comment Share on other sites More sharing options...
pulpfiction Posted March 9, 2006 Share Posted March 9, 2006 you can check it in two steps, is this what you are looking for?dim val'checks if atleast 1 record is presentif rs.RecordCount = 0 Then Response.Write " No Record Present" End If IF NOT RS.EOF THENval = RS("sv_no")END IF'to check if supervisor number is nullIF (Len(val) = 0) OR (IsNull(val)) THENresponse.write "Error: supervisor_no is NULL"END IF Link to comment Share on other sites More sharing options...
vadder85 Posted March 10, 2006 Author Share Posted March 10, 2006 hey,tq 4 da solution..i managed to display the error message according to my requirement..tq again.. Link to comment Share on other sites More sharing options...
vadder85 Posted March 10, 2006 Author Share Posted March 10, 2006 i have another problem...let say my code...if staff_no="46" then 'here i want the coding to do nothingelse'below here are my sql statement------------------------------------------this is just exceptional statement..but i don't know the right coding..can someone give the coding for statement 'here i want the coding to do nothing means the program will have to do nothing if the staff_no equal to 46tq.... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now