Imports System.Data
Imports System.Data.SqlClient
Partial Class vendor_ListCheck
Inherits System.Web.UI.Page
Dim con As New SqlConnection(Udf.WKConnectionString)
Dim dt As New DataTable
Sub bindata()
Dim ad As New SqlDataAdapter("select * from dbo.ListData", con)
ad.Fill(dt)
With GridView1
.DataSource = dt
.DataBind()
End With
End Sub
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.SqlClient
Partial Public Class Udf
Public Shared Function WKConnectionString() As String
'資料庫連線字串
Dim connString As String = ConfigurationManager.ConnectionStrings("WorkOrderConnectionString").ConnectionString
Return connString
End Function
Public Shared Function Get_us(ByVal st1 As String) As String
Dim DB As String
DB = ""
Dim connStr As String
connStr = "Password=123;Persist Security Info=True;User ID=jea22s;Initial Catalog=222r;Data Source=12222"
Dim conn As New SqlConnection(connStr)
conn.Open()
Dim SQLStr As String
SQLStr = "SELECT unit.name_ FROM unit INNER JOIN us ON unit.unid = us.unit WHERE (us.uid = '" & st1 & "')"
Dim cmd As New SqlCommand(SQLStr, conn)
Dim reader As SqlDataReader = cmd.ExecuteReader()
If reader.Read() Then
DB = reader.Item(0)
End If
reader.Close()
conn.Close()
conn = Nothing
Return DB
End Function
沒有留言:
張貼留言