3月 26, 2009

接Return參數


Protected Sub btn_Check_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_Check.Click
        Me.SqlDataSource1.SelectParameters("學號").DefaultValue = Me.txt_Stu1_ID.Text
        Me.SqlDataSource1.Select(DataSourceSelectArguments.Empty)
       
    End Sub


    Protected Sub SqlDataSource1_Selected(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SqlDataSource1.Selected
        Dim cmd As IDbCommand = e.Command
        Dim Return_Param As SqlParameter
        Return_Param = CType(cmd.Parameters("@RETURN"), SqlParameter)


        If Return_Param.Value > 0 Then
            Me.Label1.Text = "重複申請!!"
        Else


            sds_SingleApplyDetailsWithCommit.Insert()
            Response.Redirect("申請成功.aspx")
        End If
    End Sub


3月 11, 2009

sp charindex


declare @tCount as int
 --declare @學號 nvarchar(50)
 --SET @學號 = '55,5'

 
 SELECT  @tCount = Count(*)
 from
 (
  SELECT [學號] FROM [床位申請明細_個人]
  UNION ALL
  SELECT [學號] FROM [床位申請明細_團體]
 ) AS TMP_TABLE
    --where  [學號]=@學號
 where CHARINDEX([學號],@學號) > 0
 --開必殺技=無敵
 select @tCount AS tCount
 
 return @tCount;