'----自己寫的----
Imports System
Imports System.Web.Configuration
Imports System.Data
Imports System.Data.SqlClient
'----自己寫的----
Imports System
Imports System.Web.Configuration
Imports System.Data
Imports System.Data.SqlClient
'----自己寫的----
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Conn As SqlConnection = New SqlConnection
Conn.ConnectionString = WebConfigurationManager.ConnectionStrings("Web.Config檔案裡面 ConnectionString").ConnectionString
Conn.Open() '---- 連結DB
Dim Conn As SqlConnection = New SqlConnection
Conn.ConnectionString = WebConfigurationManager.ConnectionStrings("Web.Config檔案裡面 ConnectionString").ConnectionString
Conn.Open() '---- 連結DB
Dim dr As SqlDataReader = Nothing
Dim cmd As SqlCommand
cmd = New SqlCommand("
dr = cmd.ExecuteReader() '---- 執行SQL指令,取出資料
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////
If dr.HasRows() Then
Response.Write("Error~ 找到相同的帳號,所以程式停止!!")
Response.End()
Else '-- 沒有找到相同標題的文章,所以可以新增這筆資料 '-- 請自己撰寫資料新增的程式碼
Response.Write("新增資料成功!!")
End If
If Not (dr Is Nothing) Then
cmd.Cancel()
dr.Close()
End If
'---- Close the connection when done with it.
If (Conn.State = ConnectionState.Open) Then
Conn.Close()
Conn.Dispose()
End If
End Sub
沒有留言:
張貼留言