Error :
CrystalReportViewer - CrystalReportViewer1
Use ReportSource or DataBindings property to specify a report source.
Code behind page of following error:
Public Class rptspeedwise
Inherits System.Web.UI.Page
Dim obj As New login
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents lbluser As System.Web.UI.WebControls.Label
Protected WithEvents lblarea As System.Web.UI.WebControls.Label
Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
Dim da As New SqlClient.SqlDataAdapter
Dim i As Integer
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents rptspeedwise_cmb_name As System.Web.UI.WebControls.DropDownList
Protected WithEvents rptspeedwise_txt As System.Web.UI.WebControls.TextBox
Protected WithEvents rptspeedwise_btn_display As System.Web.UI.WebControls.Button
Protected WithEvents rptspeedwise_btn_cancel As System.Web.UI.WebControls.Button
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If log1 = False And obj.a = "" And obj.b = "" And Session("frmlogin_var_pwdmain") = "" And Session("frmlogin_var_uname") = "" Then
Response.Redirect("login.aspx")
Exit Sub
End If
If Not Page.IsPostBack Then
Dim mycon6 As SqlClient.SqlConnection
mycon6 = New SqlClient.SqlConnection(ConfigurationSettings.AppSettings("constr"))
mycon6.Open()
lbluser.Text = Session("frmlogin_var_uname")
lblarea.Text = Session("frmlogin_var_area")
da = New SqlClient.SqlDataAdapter("select * from offsale.user_details(nolock) where username='" & Session("frmlogin_var_uname") & "' and rspeed='True' and areaid = " & Session("frmlogin_var_areaid"), mycon6)
Dim dt As New DataTable
da.Fill(dt)
da.Dispose()
If dt.Rows.Count <> 0 Then
dt.Dispose()
rptspeedwise_cmb_name.Items.Add("Select")
rptspeedwise_cmb_name.Items.Add("=")
rptspeedwise_cmb_name.Items.Add(">")
rptspeedwise_cmb_name.Items.Add(">=")
rptspeedwise_cmb_name.Items.Add("<")
rptspeedwise_cmb_name.Items.Add("<=")
Else
dt.Dispose()
Label2.Visible = True
rptspeedwise_btn_cancel.Enabled = True
rptspeedwise_btn_display.Enabled = False
rptspeedwise_cmb_name.Enabled = False
rptspeedwise_txt.Enabled = False
Label2.Text = "Access Denied,Hence Simultaneous Access by two admins"
End If
mycon6.Close() : mycon6.Dispose()
End If
End Sub
Private Sub rptspeedwise_btn_display_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rptspeedwise_btn_display.Click
Label2.Visible = True
If rptspeedwise_cmb_name.SelectedValue = "Select" Then
Label2.Text = "Select Clause"
Exit Sub
End If
If Val(rptspeedwise_txt.Text) = 0 Or rptspeedwise_txt.Text = "" Then
Label2.Visible = True
Label2.Text = "Check Speed Value"
Exit Sub
End If
Session("speedwise") = rptspeedwise_cmb_name.SelectedValue
Session("logiopr") = rptspeedwise_txt.Text
Dim mycon1 As New SqlClient.SqlConnection
mycon1 = New SqlClient.SqlConnection(ConfigurationSettings.AppSettings("constr"))
mycon1.Open()
da = New SqlClient.SqlDataAdapter("select distinct offsale.timeticket_fullCT.*,type,stop,speed,ns,capacity,base_hours,offsale.jobunits.status,offsale.areas.areaname,'" & rptspeedwise_cmb_name.SelectedValue & "' as logiopr," & rptspeedwise_txt.Text & " as speedwise,project_name from offsale.jobunits(nolock),offsale.jobdetails(nolock),offsale.timeticket_fullCT(nolock),offsale.areas(nolock) where offsale.jobunits.job_no = offsale.jobdetails.job_no and offsale.jobdetails.areaid=" & Session("frmlogin_var_areaid") & " and isnull(offsale.jobdetails.active,'')='Y' and offsale.areas.areaid=" & Session("frmlogin_var_areaid") & " and offsale.jobunits.speed" & rptspeedwise_cmb_name.SelectedValue & rptspeedwise_txt.Text & " and offsale.timeticket_fullCT.job_no = offsale.jobunits.job_no and offsale.timeticket_fullCT.unit_no = offsale.jobunits.unit_no", mycon1)
Dim dt As New DataTable
da.Fill(dt)
da.Dispose()
'dt.Dispose()
mycon1.Close() : mycon1.Dispose()
If dt.Rows.Count <> 0 Then
dt.Dispose()
Dim mycon2 As New SqlClient.SqlConnection
mycon2 = New SqlClient.SqlConnection(ConfigurationSettings.AppSettings("constr"))
mycon2.Open()
Dim mycom2 As New SqlClient.SqlCommand("delete from offsale.rpspeedwise where username ='" & Session("frmlogin_var_uname") & "'", mycon2)
' Dim mycom2 As New SqlClient.SqlCommand("delete from rpspeedwise", mycon)
mycom2.ExecuteNonQuery()
mycom2.Dispose()
mycon2.Close() : mycon2.Dispose()
Dim mycon3 As New SqlClient.SqlConnection
mycon3 = New SqlClient.SqlConnection(ConfigurationSettings.AppSettings("constr"))
mycon3.Open()
Dim mycom3 As New SqlClient.SqlCommand("insert into offsale.rpspeedwise(actualhours,A,B,C,D,E,F,G,H,I,J,K,L,job_no,unit_no,type ,stop ,speed,ns,capacity,base_hours,manhrs,status,areaname, logiopr, speedwise,project_name ,username) select distinct offsale.timeticket_fullCT.actualhours,offsale.timeticket_fullCT.A,offsale.timeticket_fullCT.B,offsale.timeticket_fullCT.C,offsale.timeticket_fullCT.D,offsale.timeticket_fullCT.E,offsale.timeticket_fullCT.F,offsale.timeticket_fullCT.G,offsale.timeticket_fullCT.H,offsale.timeticket_fullCT.I,offsale.timeticket_fullCT.J,offsale.timeticket_fullCT.K,offsale.timeticket_fullCT.L,offsale.timeticket_fullCT.job_no,offsale.timeticket_fullCT.unit_no,type ,stop ,speed,ns,capacity,base_hours+manhrs as base_hours,manhrs,offsale.jobunits.status,offsale.areas.areaname,'" & rptspeedwise_cmb_name.SelectedValue & "' as logiopr," & rptspeedwise_txt.Text & " as speedwise,project_name ,'" & Session("frmlogin_var_uname") & "' as username from offsale.jobunits(nolock),offsale.jobdetails(nolock),offsale.timeticket_fullCT(nolock),offsale.areas(nolock) where offsale.jobunits.job_no = offsale.jobdetails.job_no and offsale.jobdetails.areaid=" & Session("frmlogin_var_areaid") & " and isnull(offsale.jobdetails.active,'')='Y' and offsale.timeticket_fullCT.job_no = offsale.jobdetails.job_no and offsale.areas.areaid=" & Session("frmlogin_var_areaid") & " and offsale.jobunits.speed" & rptspeedwise_cmb_name.SelectedValue & rptspeedwise_txt.Text & " and offsale.timeticket_fullCT.job_no = offsale.jobunits.job_no", mycon3)
mycon3.BeginTransaction.Commit()
mycom3.ExecuteNonQuery()
mycom3.Dispose()
mycon3.Close() : mycon3.Dispose()
''''
CreateNewDataRow()
''''
Label2.Visible = False
'rptid = "rptspeedwise"
' Session("Rptid") = "rptspeedwise"
Session("Rptid") = "offsale.rptspeedwise"
Response.Redirect("crjobtilldate.aspx?target=head " & Session("eta") & Rnd())
'Response.Redirect("cryspeedwise.aspx")
Else
Label2.Text = "No Record Found"
dt.Dispose()
' mycon.Close() : mycon.Dispose()
End If
End Sub
Private Sub CreateNewDataRow()
' Use the MakeTable function below to create a new table.
Dim mycon4 As New SqlClient.SqlConnection
mycon4 = New SqlClient.SqlConnection(ConfigurationSettings.AppSettings("constr"))
mycon4.Open()
Dim myTable As DataTable
myTable = MakeNamesTable()
da = New SqlClient.SqlDataAdapter("select max(timeticket_date),offsale.rpspeedwise.job_no from offsale.time_ticket,offsale.rpspeedwise where offsale.time_ticket.job_no =offsale.rpspeedwise.job_no and username='" & Session("frmlogin_var_uname") & "' group by offsale.rpspeedwise.job_no", mycon4)
Dim dt1 As New DataTable
da.Fill(dt1)
da.Dispose()
mycon4.Close() : mycon4.Dispose()
Dim myRow As DataRow
Dim j As Integer
For j = 0 To dt1.Rows.Count - 1
myRow = myTable.NewRow()
' Then add the new row to the collection.
myRow("Maxttdate") = dt1.Rows(j).Item(0)
myRow("JobNo") = dt1.Rows(j).Item(1)
myTable.Rows.Add(myRow)
Next
dt1.Dispose()
Dim dc As DataColumn
For Each dc In myTable.Columns
Console.WriteLine(dc.ColumnName)
Next
Dim i As Integer
i = myTable.Rows.Count
Dim mycon5 As New SqlClient.SqlConnection
mycon5 = New SqlClient.SqlConnection(ConfigurationSettings.AppSettings("constr"))
mycon5.Open()
While i > 0
Dim mycom As New SqlClient.SqlCommand("update offsale.rpspeedwise set maxttdate='" & myTable.Rows(i - 1).Item(0) & "' where job_no='" & myTable.Rows(i - 1).Item(1) & "' and username='" & Session("frmlogin_var_uname") & "'", mycon5)
mycom.ExecuteNonQuery()
mycom.Dispose()
i = i - 1
End While
mycon5.Close() : mycon5.Dispose()
End Sub
Private Function MakeNamesTable() As DataTable
' Create a new DataTable titled 'Names.'
Dim namesTable As DataTable = New DataTable("Names")
' Add three column objects to the table.
Dim fNameColumn As DataColumn = New DataColumn
fNameColumn.DataType = System.Type.GetType("System.DateTime")
fNameColumn.ColumnName = "Maxttdate"
namesTable.Columns.Add(fNameColumn)
Dim lNameColumn As DataColumn = New DataColumn
lNameColumn.DataType = System.Type.GetType("System.String")
lNameColumn.ColumnName = "JobNo"
namesTable.Columns.Add(lNameColumn)
' Create an array for DataColumn objects.
' Return the new DataTable.
MakeNamesTable = namesTable
End Function
Private Sub rptspeedwise_btn_cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rptspeedwise_btn_cancel.Click
Response.Redirect("Mainform.aspx")
End Sub
End Class
Tags: Visual Basic