2012年12月18日 星期二

前端綁定Eval數據

VB.Net:xxx(eval("field"))
C#:xxx(Eval("field").ToString())

Give me i want 加強版

    Public Shared Function Gmiw(ByVal com As String, ByVal rol As Integer, ByVal col As Integer, Optional ByVal conn As String = "ConnectionString") As String
        Try
            Dim db As New SysDb(conn)
            If Left(com.Trim, 6).ToLower = "select" Then
                db.SelectCommand = com
                Dim dv As Data.DataView = db.Select(New DataSourceSelectArguments)
                If dv.Count > 0 Then
                    Return dv.Item(rol).Item(col)
                Else
                    Return ""
                End If
            ElseIf Left(com.Trim, 6).ToLower = "insert" Then
                db.InsertCommand = com
                Return db.Insert()
            ElseIf Left(com.Trim, 6).ToLower = "update" Then
                db.UpdateCommand = com
                Return db.Update()
            ElseIf Left(com.Trim, 6).ToLower = "delete" Then
                db.DeleteCommand = com
                Return db.Delete()
            Else
                Return ""
            End If
        Catch ex As Exception
            LastError = ex.Message
            'MsgBox("GetPersonalInfo:" & ex.Message)
            Return ""
        End Try
    End Function

查詢資料是否存在 by MSSQL


Public Shared Function isDataExist(ByVal sql As String) As Boolean
Dim db As New SysDb
db.SelectCommand = sql
Dim dv As Data.DataView = db.Select(New DataSourceSelectArguments)
If dv.Count > 0 Then
Return True
Else
Return False
End If
End Function

textbox轉txt文字檔


Imports system.io

Dim path As String = "c:\test.doc"
Dim fs As filestream
If file.exists(path) = False Then
fs = file.create(path)
Dim info As Byte() = New UTF8Encoding(True).GetBytes(me.textbox1.text)
fs.write(info, 0, info.length)
fs.close()
End If