Sample code:
Try
Dim constr As String = ConfigurationManager.ConnectionStrings("FileDBConnectionString").ConnectionString
Using con As New SqlConnection(constr)
Using cmd As New SqlCommand()
'cmd.CommandText = "SELECT fldControlno, fldRecno, fldFileName ,fldDate FROM tblPDSTrainzATemp where fldRecno= ('" & txtrecordno.Text & "')" Convert(varchar, fldDate, 101)
'
cmd.CommandText = "SELECT fldcontrolno,fldEmpID,Convert(varchar, fldDate, 101) as [Date],fldPosition, fldSalary, fldAttachType, fldfilename,fldfiletype,fldfiledata FROM tblCOS"
cmd.Connection = con
con.Open()
GridCOS.DataSource = cmd.ExecuteReader()
GridCOS.DataBind()
con.Close()
End Using
End Using
Catch ex As Exception
'Session.Add("ErrorMessage", ex.Message)
'Response.Redirect("~/errorpage.aspx")
MsgBox(ex.Message)
End Try
jay.perez.167189 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.