Private Sub getData3(ByVal user As String)
Dim table As New DataTable()
Dim connStr As String = ConfigurationManager.ConnectionStrings("testConnectionString").ConnectionString.ToString()
Dim conn As New SqlConnection(connStr)
conn.Open()
Dim sqlCmd As New SqlCommand("SELECT * from Table_ครุภัณฑ์9 where H_deviceID = @deviceID", conn)
Dim sqlDa As New SqlDataAdapter(sqlCmd)
sqlCmd.Parameters.AddWithValue("@deviceID", user)
sqlDa.Fill(table)
If table.Rows.Count > 0 Then
txt_G_storeName.Text = table.Rows(0)("H_storeName").ToString()
End If
conn.Close()
End Sub
Tag : .NET, Ms SQL Server 2005, Web (ASP.NET), VB.NET
Sub Page_Load(sender As Object, e As EventArgs)
strConnString = "Server=localhost;Uid=sa;PASSWORD=;database=mydatabase;Max Pool Size=400;Connect Timeout=600;"
objConn.ConnectionString = strConnString
objConn.Open()
IF Not Page.IsPostBack() Then
ViewData()
End IF
End Sub
Sub ViewData()
'*** DataTable ***'
Dim dtAdapter As SqlDataAdapter
Dim dt As New DataTable
strSQL = "SELECT * FROM customer WHERE CustomerID = '"& Request.QueryString("CustomerID") &"' "
dtAdapter = New SqlDataAdapter(strSQL, objConn)
dtAdapter.Fill(dt)
If dt.Rows.Count > 0 Then
Me.txtCustomerID.Text = dt.Rows(0)("CustomerID")
Me.txtName.Text = dt.Rows(0)("Name")
Me.txtEmail.Text = dt.Rows(0)("Email")
Me.txtCountryCode.Text = dt.Rows(0)("CountryCode")
Me.txtBudget.Text = dt.Rows(0)("Budget")
Me.txtUsed.Text = dt.Rows(0)("Used")
End IF
End Sub