Thursday, April 9, 2015

Using Crystal Report with run time user defined query base data source and run .net 2 and .net 4 framework web portal integrated mode

Using Crystal Report with run time user defined query base data source and run .net 2 and .net 4 framework web portal integrated mode

Many type of error occur while attempting Asp.net 4.0 web portal starting to run on 32 bit windows, So, just do like this. Mean, first go via command prompt with aspnet_regiis.exe -i command on .net 4 framework as per picture then simply configure application pools to run in integrated mode on 2 and 4 frameworks. Here I had created two Crystal Reports as just i had placed web folder under my existing JA application folder like c:/inetpub/wwwroot/JA/web then via JA/Login.aspx etc were accessed and for report just link to JA/web/Pmain.aspx report and it worked where JA contain .net 2 framework application and JA/Web contain .net 4 framework application. here web config file accordingly. ..........................................For JA................... .....................................................For JA/Web...............
.................................. with precompiled................. ..................................................................... Coding are as below:= <%@ Page Language="VB" %> <%@ Register TagPrefix="CR" Namespace="CrystalDecisions.Web" Assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" %> <%@ import Namespace="System.Data.Sqlclient" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Web.UI.WebControls" %> <%@import Namespace="System.Data.OleDb" %> Sub back(ByVal sender As Object, ByVal e As EventArgs) Response.Redirect("\JA\Login.aspx") End Sub Sub PR(ByVal sender As Object, ByVal e As EventArgs) Response.Redirect("PR.aspx") End Sub Sub Page_Load If Not Page.IsPostBack Then 'Dim conn As New SqlConnection("Data Source=.\SQLEXPRESS1 ;Initial Catalog=ELECTION; Integrated Security=SSPI;") 'Dim adp As New SqlDataAdapter("select * from ELECTION where PID='3'", conn) 'Dim dset As New Data.DataSet Dim conn1 As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & """" & "C:\Inetpub\wwwroot\JA\mnp.mdb" & """") Dim adp1 As New OleDbDataAdapter("select * from JANTA", conn1) Dim dset1 As New Data.DataSet adp1.Fill(dset1, "JANTA") CrystalReportSource1.ReportDocument.SetDataSource(dset1) CrystalReportSource1.DataBind() CrystalReportViewer1.ReportSource = CrystalReportSource1 CrystalReportViewer1.DataBind() End If End Sub Sub find(ByVal sender As Object, ByVal e As EventArgs) On Error Resume Next Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & """" & "C:\Inetpub\wwwroot\JA\mnp.mdb" & """") Dim st As String st = "select * from JANTA where Ticket_No=" & TextBox1.Text Dim adp As New OleDbDataAdapter(st, conn) Dim dset As New Data.DataSet adp.Fill(dset, "JANTA") CrystalReportSource1.ReportDocument.SetDataSource(dset) CrystalReportSource1.DataBind() CrystalReportViewer1.ReportSource = CrystalReportSource1 CrystalReportViewer1.DataBind() End Sub ................................................ I had created two crystal report seperately. as well as using date diff function, pending case query may be accessed like - Sub pending(ByVal sender As Object, ByVal e As EventArgs) Dim str As String Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & """" & "C:\Inetpub\wwwroot\JA\mnp.mdb" & """") Dim dset As New Data.DataSet str="update JANTA set Pending_Days = DateDiff(" & """" & "d" & """" & ", Representation_Receiving_Date, Now()) where Ticket_No = Ticket_No" Dim adp As New OleDbDataAdapter(str, conn) adp.Fill(dset, "JANTA") Response.Redirect("pending.aspx") conn.Close() End Sub in some case where crystal report data source set to be with msaccess data source control then in that case , query may be provided directly under control tag like and his web config is

Tuesday, April 7, 2015

Creating add new record aspx.net web application page using textbox validation RegularExpressionValidator and RequiredFieldValidator fileupload control with datagrid and label uploaded file link


Creating add new record aspx.net web application page using textbox validation RegularExpressionValidator and RequiredFieldValidator fileupload control with datagrid and label uploaded file link
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & """" & "C:\Inetpub\wwwroot\JA\mnp.mdb" & """") Dim adp As New OleDbDataAdapter("select * from JANTA", conn) Dim dset As New Data.DataSet Dim sql As String Sub Page_Load() Dim conn1 As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & """" & "C:\Inetpub\wwwroot\JA\mnp.mdb" & """") Dim adp1 As New OleDbDataAdapter("select max(Ticket_no) from JANTA", conn) Dim dset1 As New Data.DataSet adp1.Fill(dset1, "JANTA") TextBox1.Text = Now() Label20.Text = "Last Ticket No. is: " & dset1.Tables(0).Rows(0).Item(0) End Sub Sub add(ByVal sender As Object, ByVal e As EventArgs) If TextBox8.Text <> "" And IsNumeric(TextBox8.Text) = False Then TextBox8.Text = " Please Enter contact number in valid digit format" conn.Close() Exit Sub End If If TextBox1.Text = "" Or TextBox2.Text = "" Then TextBox1.Text = " PLEASE ENTER DATA BEFORE ADD " conn.Close() Exit Sub Else If FileUpload1.HasFile And FileUpload1.PostedFile.ContentLength < 4096000 And FileUpload1.PostedFile.ContentType = "application/pdf" Then Try FileUpload1.SaveAs("C:\Inetpub\wwwroot\JA\images\" & _ FileUpload1.FileName) Label60.Text = " Uploaded successfully, Please note down above Ticket no. for future tracking of your application, uploaded File name: " & _ FileUpload1.PostedFile.FileName & "
" & _ "File Size: " & _ FileUpload1.PostedFile.ContentLength & " kb
" & _ "Content type: " & _ FileUpload1.PostedFile.ContentType Catch ex As Exception Label60.Text = "ERROR: " & ex.Message.ToString() End Try Else Label60.Text = "You have not specified a valid file [.pdf], So, your document uploading have failure, Please submit this document at office in person." End If Dim doc As String = " " & FileUpload1.FileName & "" sql = "insert into JANTA(Representation_Receiving_Date, Applicant_Name, Father_or_Husband_Name, Address, Post_Office, Police_Station, Sub_Division, Contact_No, Complain_Description, Applicant_document) values ('" & Now() & "', '" & TextBox2.Text & "', '" & TextBox3.Text & "', '" & TextBox4.Text & "', '" & TextBox5.Text & "', '" & TextBox6.Text & "', '" & TextBox7.Text & "', '" & TextBox8.Text & "', '" & TextBox9.Text & "', '" & doc & "')" If conn.State = Data.ConnectionState.Closed Then conn.Open() adp = New OleDbDataAdapter adp.InsertCommand = New OleDbCommand(sql, conn) adp.InsertCommand.ExecuteNonQuery() TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = "" TextBox5.Text = "" TextBox6.Text = "" TextBox7.Text = "" TextBox8.Text = "" TextBox9.Text = "" Page_Load() End If End If End Sub Sub back(ByVal sender As Object, ByVal e As EventArgs) Response.Redirect("login.aspx") End Sub 'Sub upload1(ByVal sender As Object, ByVal e As EventArgs) 'If FileUpload1.HasFile Then 'Try 'FileUpload1.SaveAs("C:\Inetpub\wwwroot\JA\images\" & _ ' FileUpload1.FileName) ' Label6.Text = "File name: " & _ ' FileUpload1.PostedFile.FileName & "
" & _ '"File Size: " & _ ' FileUpload1.PostedFile.ContentLength & " kb
" & _ '"Content type: " & _ ' FileUpload1.PostedFile.ContentType 'Catch ex As Exception ' Label6.Text = "ERROR: " & ex.Message.ToString() 'End Try 'Else ' Label6.Text = "You have not specified a file." ' End If ' End Sub

here html code : TextBox ID="TextBox2" runat="server" Width="224px" asp:TextBox asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox2" Display="Dynamic" ErrorMessage="should not be blank !!" asp:RequiredFieldValidator TextBox ID="TextBox4" runat="server" TextMode="MultiLine" Width="224px" asp:TextBox asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox4" Display="Dynamic" ErrorMessage="should not be blank !!" asp:RequiredFieldValidator

Label ID="Label8" runat="server" Font-Bold="True" ForeColor="White" Text="Mobile No.:" Width="120px" asp:Label                          asp:TextBox ID="TextBox8" runat="server" Width="224px" asp:TextBox asp:RegularExpressionValidator Display = "Dynamic" ControlToValidate = "TextBox8" ID="RegularExpressionValidator3" ValidationExpression = "^[\s\S]{10,10}$" runat="server" ErrorMessage="Minimum and Maximum 10 characters for mobile number required." asp:RegularExpressionValidator   

asp:Label ID="Label60" runat="server" Style="z-index: 101; left: 763px; position: absolute; top: 376px" Width="305px" Height="213px" ForeColor="White" asp:Label
asp:FileUpload ID="FileUpload1" runat="server" Style="z-index: 102; left: 820px; position: absolute; top: 658px"

  asp:Label ID="Label13" runat="server" Font-Bold="True" Style="z-index: 105; left: 609px; position: absolute; top: 629px" Text='Please upload only ".pdf" document of size less then 4 mb otherwise documnet upload will not happen, and skiped:' Width="192px" ForeColor="White" Height="63px"asp:Label  .......................... after add record successfully : and report look : here i am providing facility to open/download user/department attached file to client side directly what ever in .pdf format under 4 mb size as uploaded by user/department by FileUpload Control. as well as I am also providing runtime client side textbox entry validation using asp:RegularExpressionValidator for expression and asp:RequiredFieldValidator, other custom field validator may be used also as per need. in this way, you may write your custom function/sub function as usual to run after event. here i am sending html a href code with fileupload control posted file name with server file location to database userfile field which inturn converted to real link of file in datagrid as well as label. FileUpload1.SaveAs("C:\Inetpub\wwwroot\JA\images\" & _ FileUpload1.FileName) and Dim doc As String = " " & FileUpload1.FileName & "" in insert command. Dim doc As String = " " & FileUpload1.FileName & "" sql = "insert into JANTA(Representation_Receiving_Date, Applicant_Name, Father_or_Husband_Name, Address, Post_Office, Police_Station, Sub_Division, Contact_No, Complain_Description, Applicant_document) values ('" & Now() & "', '" & TextBox2.Text & "', '" & TextBox3.Text & "', '" & TextBox4.Text & "', '" & TextBox5.Text & "', '" & TextBox6.Text & "', '" & TextBox7.Text & "', '" & TextBox8.Text & "', '" & TextBox9.Text & "', '" & doc & "')" and while using it for label Label14.Text = dset.Tables(0).Rows(0).Item(22) where item(22) mean data table 22th column for user uploaded file location field here file upload function while using it for updates page If FileUpload1.HasFile And FileUpload1.PostedFile.ContentLength < 4096000 And FileUpload1.PostedFile.ContentType = "application/pdf" Then Try FileUpload1.SaveAs("C:\Inetpub\wwwroot\JA\images\" & _ FileUpload1.FileName) Label60.Text = " Uploaded successfully, Please note down above Ticket no. for future tracking of your application, uploaded File name: " & _ FileUpload1.PostedFile.FileName & "
" & _ "File Size: " & _ FileUpload1.PostedFile.ContentLength & " kb
" & _ "Content type: " & _ FileUpload1.PostedFile.ContentType Catch ex As Exception Label60.Text = "ERROR: " & ex.Message.ToString() End Try Else Label60.Text = "You have not specified a valid file [.pdf], So, your document uploading have failure, Please submit this document at office in person." End If Dim doc As String = " " & FileUpload1.FileName & "" str = "update JANTA set Representation_Receiving_Date='" & TextBox1.Text & "', Applicant_Name='" & TextBox2.Text & "', Father_or_Husband_Name='" & TextBox3.Text & "', Address='" & TextBox4.Text & "', Post_Office='" & TextBox5.Text & "', Police_Station='" & TextBox6.Text & "', Sub_Division='" & TextBox7.Text & "', Contact_No=" & TextBox8.Text & ", Complain_Description='" & TextBox9.Text & "', Applicant_Document='" & doc & "' where Ticket_No = " & TextBox00.Text If TextBox0.Text = "pass code" Then Dim adp As New OleDbDataAdapter(str, conn) adp.Fill(dset, "JANTA") Response.Redirect("edit.aspx") conn.Close() Else TextBox0.Text = "wrong password" End If as well as i provide find button for code - Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & """" & "C:\Inetpub\wwwroot\JA\mnp.mdb" & """") Dim st As String st = "select * from JANTA where Ticket_No=" & TextBox00.Text Dim adp As New OleDbDataAdapter(st, conn) Dim dset As New Data.DataSet adp.Fill(dset, "JANTA") TextBox1.Text = dset.Tables(0).Rows(0).Item(0) TextBox2.Text = dset.Tables(0).Rows(0).Item(2) TextBox3.Text = dset.Tables(0).Rows(0).Item(3) TextBox4.Text = dset.Tables(0).Rows(0).Item(4) TextBox5.Text = dset.Tables(0).Rows(0).Item(5) TextBox6.Text = dset.Tables(0).Rows(0).Item(6) TextBox7.Text = dset.Tables(0).Rows(0).Item(7) TextBox8.Text = dset.Tables(0).Rows(0).Item(8) TextBox9.Text = dset.Tables(0).Rows(0).Item(9) 'TextBox10.Text = dset.Tables(0).Rows(0).Item(22) Label14.Text = dset.Tables(0).Rows(0).Item(22) conn.Close() in loading tiket no. use : Sub Page_Load() Dim conn1 As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & """" & "C:\Inetpub\wwwroot\JA\mnp.mdb" & """") Dim adp1 As New OleDbDataAdapter("select max(Ticket_no) from JANTA", conn) Dim dset1 As New Data.DataSet adp1.Fill(dset1, "JANTA") TextBox1.Text = Now() Label20.Text = "Last Ticket No. is: " & dset1.Tables(0).Rows(0).Item(0) End Sub for delete command using pass code password: Dim str As String Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & """" & "C:\Inetpub\wwwroot\JA\mnp.mdb" & """") Dim dset As New Data.DataSet If DropDownList1.SelectedItem.Text = "Ticket_No" Then str = "delete from JANTA where Ticket_No=" & TextBox8.Text Else str = "delete from JANTA where " & DropDownList1.SelectedItem.Text & "='" & TextBox8.Text & "'" End If If TextBox9.Text = "pass code" Then Dim adp As New OleDbDataAdapter(str, conn) adp.Fill(dset, "JANTA") Response.Redirect("delete.aspx") conn.Close() Else TextBox9.Text = "wrong passc code" conn.Close() End If

How to use IIS7 over windows 32 bit OS and avoiding HTTP Error 404.3 - Not found and Server Error in '\' Application Operation must use an updateable query & enable firewall in windows 7 as well as granting permisson for allowing http server for asp.net

" How to use IIS7 over windows 32 bit OS and avoiding HTTP Error 404.3 - Not found and Server Error in '\' Application Operation must use an updateable query "
 
 and other common error like
 
To start asp.net working on windows 32 bit windows7 OS just go to control panel-> programs and features -> turn windows features on or off-> then select all box and sub box after expending related to internet information server as below then you will get your IIS 7 working like this : and after pasting your asp.net web application in c:/inetpub/wwwroot directory you can run your web application like this after this, you will get second common error when you will try to access your MS-Access database in write mode mean for adding / edit / update any row record like this to solve this error you will have to assign full control for IIS user in database file as well as windows web application directory like this and as well as you will have to do same for MS-Access DB file like then your record addition work will happen enable firewall in windows 7 as well as granting permisson for allowing http server for asp.net by following steps ...................................... ......................................... ........................................... ..................................