01.
Imports
System.Data
02.
Imports
System.Data.SqlClient
03.
Imports
System.IO
04.
05.
06.
Partial
Class
editNews
07.
Inherits
System.Web.UI.Page
08.
Dim
conn
As
New
SqlConnection
09.
Dim
ds
As
New
DataSet
10.
Dim
dt
As
DataRow
11.
Dim
newid
As
Integer
12.
13.
Protected
Sub
Page_Load(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Load
14.
Dim
strConn
As
String
15.
strConn =
"Data Source=192.168.1.95;Initial Catalog=PublicReportDB;user id=sa;password = p@ssw0rd;"
16.
With
conn
17.
18.
If
.State = ConnectionState.Open
Then
.Close()
19.
.ConnectionString = strConn
20.
.Open()
21.
End
With
22.
23.
newid = Request.QueryString(
"newid"
)
24.
25.
Dim
SelectCommand
As
String
=
"SELECT * FROM news WHERE newid = '"
& newid &
"' "
26.
Dim
da
As
New
SqlDataAdapter(SelectCommand, conn)
27.
da.Fill(ds,
"select"
)
28.
dt = ds.Tables(
"select"
).Rows(0)
29.
lbldate.Text = dt(
"date"
)
30.
txtTitle.Text = dt(
"title"
)
31.
txtDetail.Text = dt(
"detail"
)
32.
imgEdit.ImageUrl =
"upload/"
& dt(
"fileupload"
)
33.
End
Sub
34.
Protected
Sub
btnCon_Click(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
btnCon.Click
35.
36.
Dim
UpdateCommand
As
String
37.
38.
UpdateCommand =
" UPDATE news "
& _
39.
" SET title ='"
& txtTitle.Text &
"',"
& _
40.
" detail ='"
& txtDetail.Text &
"',"
& _
41.
" fileupload ='"
& FileUpload1.FileName &
"'"
& _
42.
" WHERE newid ="
& newid &
""
43.
44.
Dim
com
As
New
SqlCommand(UpdateCommand, conn)
45.
With
com
46.
.Connection = conn
47.
.CommandType = CommandType.Text
48.
.CommandText = UpdateCommand
49.
.ExecuteNonQuery()
50.
End
With
51.
52.
End
Sub
53.
54.
Protected
Sub
btnCancle_Click(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
btnCancle.Click
55.
Response.Redirect(
"viewAddnews.aspx"
)
56.
End
Sub
57.
End
Class