 |
|
ดึงข้อมูลจาก sql server มาโชว์ใน textbox โดยการเขียนโค้ตด้วย vb.net ครับ |
|
 |
|
|
 |
 |
|
ตัวอย่างนี้เลยครับใช้ DataTable
Code (VB.NET)
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
Go to : ASP.NET SQL Server Edit/Update Record
|
 |
 |
 |
 |
Date :
2011-11-15 17:14:04 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณ คุณ mr.win มากครับ ...
|
 |
 |
 |
 |
Date :
2011-11-15 17:39:40 |
By :
tomon |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ของผม ASP.NET เขียนไม่ได้เลยครับ
Code (ASP)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim _q = Request.QueryString("q")
If (_q IsNot Nothing) Then
If _q.Trim() <> "" Then
Dim db As New dbIndirectDataContext()
Dim ts = From t In db.Products
Where t.Product_ID.Contains(_q)
Order By t.Product_ID Descending
Select New With {
.Product_ID = t.Product_ID,
.Product_Name = t.Product_Name,
.Product_Detail = t.Product_Detail,
.Product_Unit = t.Product_Unit,
.Product_Price = t.Product_Price,
.Product_Quantity = t.Product_Quantity
}
If ts.Count() > 0 Then
TextName.Text = ts.Intersect("Product_Name"),
TextDetail.Text = ts.Intersect("Product_Detail"),
TextUnit.Text = ts.Intersect("Product_Unit"),
TextPrice.Text = ts.Intersect("Product_Price"),
TextQuantity.Text = ts.Intersect("Product_Quantity"),
End If
Else
Response.RedirectPermanent("StockIN.aspx")
End If
End If
End Sub
Protected Sub cmdSearch_Click(sender As Object, e As System.EventArgs) Handles cmdSearch.Click
If textID.Text.Trim() <> "" Then
Response.RedirectPermanent("StockIN.aspx?q=" & textID.Text.Trim())
End If
End Sub
|
 |
 |
 |
 |
Date :
2016-09-29 16:26:39 |
By :
phumiphach |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|