Hi dharmendr this is my code,
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Data
Imports System.Data.SqlClient
Imports System.Drawing
Partial Class _Default
Inherits System.Web.UI.Page
'deklarasi uton edit delete
Private dataTable As New DataTable
Private _editButton As New ButtonColumn
Private _deleteButton As New ButtonColumn
Dim prm1type, prm2type, prm3type, prm4type, prm1Label, prm2Label, prm3Label, prm4Label As String
Dim prm1query, prm2query, prm3query, prm4query, value1, value2, value3, value4, rptname As String
'definisi string koneksi dan buka koneksi
Dim Cmd As SqlCommand
Dim Rd As SqlDataReader
Dim dt As New DataTable
Dim queryResult As Integer
'definisi string koneksi dan buka koneksi
Dim strCn As String = ConfigurationManager.ConnectionStrings("PX_FOLITEConnectionString").ToString
Dim cn As SqlConnection = New SqlConnection(strCn)
Private Function ExecuteQuery(ByVal cmd As SqlCommand, ByVal action As String) As DataTable
Dim conString As String = ConfigurationManager.ConnectionStrings("PX_FOLITEConnectionString").ConnectionString
Using con As New SqlConnection(conString)
cmd.Connection = con
Select Case action
Case "SELECT"
Using sda As New SqlDataAdapter()
sda.SelectCommand = cmd
Using dt As New DataTable()
sda.Fill(dt)
Return dt
End Using
End Using
Case "UPDATE"
con.Open()
cmd.ExecuteNonQuery()
con.Close()
Exit Select
End Select
Return Nothing
End Using
End Function
Sub readdata()
Dim id As String
id = GridView1.SelectedRow.Cells(1).Text
Dim strCn As String = ConfigurationManager.ConnectionStrings("PX_FOLITEConnectionString").ToString
Dim cn As SqlConnection = New SqlConnection(strCn)
Dim query As String = "SELECT * FROM sys_reportlist WHERE reportid= @reportid AND hotelid = 'AAA' AND propertyid = 'AAA' "
Dim cmd As New SqlCommand()
cmd.Parameters.AddWithValue("@reportid", id)
cmd.CommandType = CommandType.Text
cmd.CommandText = query
cmd.Connection = cn
Try
cn.Open()
Dim sdr As SqlDataReader = cmd.ExecuteReader()
While sdr.Read()
prm1type = sdr("prm1type").ToString
prm2type = sdr("prm2type").ToString
prm3type = sdr("prm3type").ToString
prm4type = sdr("prm4type").ToString
prm1Label = sdr("prm1label").ToString
prm2Label = sdr("prm2label").ToString
prm3Label = sdr("prm3label").ToString
prm4Label = sdr("prm4label").ToString
prm1query = sdr("prm1query").ToString
prm2query = sdr("prm2query").ToString
prm3query = sdr("prm3query").ToString
prm4query = sdr("prm4query").ToString
Session("rptname") = sdr("reportname").ToString
TextBox2.Text = sdr("reportname").ToString
End While
Catch ex As Exception
Throw ex
Finally
cn.Close()
cn.Dispose()
End Try
End Sub
Sub gridreport()
cn.Open()
Dim cmd As SqlDataAdapter = New SqlDataAdapter("SELECT reportname, reportid, reportfile FROM sys_reportlist WHERE hotelid = 'AAA' AND propertyid = 'AAA' ", cn)
Dim dt As DataTable = New DataTable()
cmd.Fill(dt)
GridView1.DataSource = dt
GridView1.DataBind()
cn.Close()
End Sub
Protected Sub OnRowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Attributes("onclick") = Page.ClientScript.GetPostBackClientHyperlink(GridView1, "Select$" & e.Row.RowIndex)
e.Row.ToolTip = "Click to select this row."
End If
End Sub
Protected Sub OnSelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles GridView1.SelectedIndexChanged
Call readdata()
Dim a As String = TextBox2.Text
Dim b As String
b = "~\Report\" + a
Dim doc As CrystalDecisions.CrystalReports.Engine.ReportDocument
doc = New CrystalDecisions.CrystalReports.Engine.ReportDocument()
doc.Load(Server.MapPath(b))
For Each t As CrystalDecisions.CrystalReports.Engine.Table In doc.Database.Tables
TextBox1.Text = t.Name
Next
For Each row As GridViewRow In GridView1.Rows
If row.RowIndex = GridView1.SelectedIndex Then
row.BackColor = ColorTranslator.FromHtml("#A1DCF2")
row.ToolTip = String.Empty
Else
row.BackColor = ColorTranslator.FromHtml("#FFFFFF")
row.ToolTip = "Click to select this row."
End If
Next
End Sub
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Call gridreport()
End Sub
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Session("ds") = TextBox1.Text
Response.Redirect("default2.aspx")
End Sub
End Class
this my html code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Default3.aspx">Add New</asp:HyperLink>
<asp:Button ID="Button1" runat="server" Text="Show" />
<asp:TextBox ID="TextBox1" runat="server" Visible="False"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" Visible="False"></asp:TextBox>
</div>
<div>
<asp:GridView ID="GridView1" runat="server" Width="700px"
AutoGenerateColumns="False"
CssClass="mGrid"
OnRowDataBound = "OnRowDataBound"
OnSelectedIndexChanged = "OnSelectedIndexChanged">
<Columns>
<asp:CommandField ButtonType="Image"
SelectImageUrl="~/icon_select.png" ShowSelectButton="true" />
<asp:BoundField DataField="reportid" HeaderText="Report ID" ItemStyle-Width="150" ItemStyle-HorizontalAlign="Center">
<ItemStyle Width="100px" />
</asp:BoundField>
<asp:BoundField DataField="reportname" HeaderText="Report Name" ItemStyle-Width="150" ItemStyle-HorizontalAlign="Center">
<ItemStyle Width="650px" />
</asp:BoundField>
<asp:BoundField DataField="reportfile" HeaderText="Report Path" ItemStyle-Width="150" ItemStyle-HorizontalAlign="Center">
<ItemStyle Width="650px" />
</asp:BoundField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
and this my server error:
Could not load file or assembly 'CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified.
you can acces my site in http://report.thepyxis.net/