A data source instance has not been supplied for the data source 'dataset2' - rdlc

i have one asp.net page with 2 reports. one report is working fine. when i run the second one its showing me this error. i have tried many solutions found in the internet. some one please help me with this
my CS code is
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/mainaccount.rdlc");
mainaccount dsmainaccount = GetData("select TB_MAIN_ACNT_NAME ,TB_MAIN_ACNT_CODE,TB_OP_BAL ,TB_CR_DT ,TB_TXN_DEBIT ,TB_TXN_CREDIT ,TB_CL_BAL_DR ,TB_CL_BAL_CR FROM FT_TRIALBAL_MPG WHERE TB_COMP_CODE='MCS' and TB_SYS_ID=233");
ReportDataSource datasourcemain = new ReportDataSource("mainaccount", dsmainaccount.Tables[0]);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(datasourcemain);
}
}
private mainaccount GetData(string query)
{
string conString = ConfigurationManager.ConnectionStrings["OrionConnectionString"].ConnectionString;
OracleCommand cmd = new OracleCommand(query);
using (OracleConnection con = new OracleConnection(conString))
{
using (OracleDataAdapter sda = new OracleDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (mainaccount dsmainaccount = new mainaccount())
{
sda.Fill(dsmainaccount, "DataTable2");
return dsmainaccount;
}
}
}
}
my aspx page code is
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"/>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font- Names="Verdana" Font-Size="8pt"
WaitMessageFont-Names="Verdana"
WaitMessageFont-Size="14pt">
<LocalReport ReportPath="mainaccount.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource2" Name="dataset2" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource2" runat="server" SelectMethod="Select" TypeName="trialbalance.mainaccount+DataTable2DataTable"> </asp:ObjectDataSource>
<br />
</div>
</form>
</body>
</html>

both reports use the same DataSet?
ReportDataSource datasourcemain = new ReportDataSource("mainaccount",dsmainaccount.Tables[1]);
which is to help the exact error that shows you in the report?

then you must fill both dataSet and transfer them to your local reporting , as shown in the following image:
here model

Related

Encrypting with public key in vb.net is producing a much different result than encrypting via jsencrypt

I am trying to send a third party an RSA encrypted string. They have provided me with a public key. I have multiple systems that need to transmit the data.
One such system is vb.net/asp.net, and is using javascript to do the encryption which works perfectly, via jsencrypt: https://unpkg.com/browse/jsencrypt#2.3.1/README.md
The result is consistently 344 characters and ends with =
I also have a desktop app in vb.net that needs to do the same, so I'm using System.Security.Cryptography.RSACryptoServiceProvider, but the result is much longer than what I see sending via the JS code. (It also doesn't end with "=" like the JS code)
The result is consistently 392 and never ends with =
Here is my vb.net code:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim strPublicKey As String = "<RSAKeyValue><Modulus>[Redacted]</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>"
Dim fStringToSend As String = "This is a test."
Dim byStringToSend As Byte() = Encoding.UTF8.GetBytes(fStringToSend)
Dim RSA As System.Security.Cryptography.RSACryptoServiceProvider = New System.Security.Cryptography.RSACryptoServiceProvider(1024)
RSA.FromXmlString(strPublicKey)
Dim strEncryptedStringToSend As String = Convert.ToBase64String(RSA.Encrypt(byStringToSend, True))
TextBox1.Text = strEncryptedStringToSend
End Sub
What am I missing? Let me know if any further data is needed to diagnose & thanks!
EDIT (adding full code, with a key I generated myself to test with)
EncTest.aspx
<%# Page Language="VB" AutoEventWireup="false" CodeFile="EncTest.aspx.vb" Inherits="EncTest" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="jsencrypt.js"></script>
<script type="text/javascript">
const publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC0qoqRSNKH+sq7mZKm9f822bhqtD4y4DIRD8++9d0zok5FQrjZHSuGc917zzUGd2IiUzRrLOt/ZMenk42/Wm55rkYf9/MsdHo94vqcHj/5yFYg3QUhgN7l7okIRfAzCkxMl/6x4RymVInB1td5F6N2mChqRm+hzWr9d0I4wLWOpwIDAQAB';
function encText() {
var textToEncrypt = 'This is a test.';
const crypt = new JSEncrypt();
crypt.setKey(publicKey);
const encryptedText = crypt.encrypt(textToEncrypt);
document.getElementById('Label2').innerHTML = encryptedText;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="net" /><br />
<br />
<asp:label ID="Label1" runat="server"></asp:label><br />
<br />
<div id="Label2"></div><br />
<br />
<div onclick="encText();">js</div>
</div>
</form>
</body>
</html>
EncTest.aspx.vb
Partial Class EncTest
Inherits System.Web.UI.Page
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim strPublicKey As String = "<RSAKeyValue><Modulus>MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC0qoqRSNKH+sq7mZKm9f822bhqtD4y4DIRD8++9d0zok5FQrjZHSuGc917zzUGd2IiUzRrLOt/ZMenk42/Wm55rkYf9/MsdHo94vqcHj/5yFYg3QUhgN7l7okIRfAzCkxMl/6x4RymVInB1td5F6N2mChqRm+hzWr9d0I4wLWOpwIDAQAB</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>"
Dim fStringToSend As String = "This is a test."
Dim byStringToSend As Byte() = Encoding.UTF8.GetBytes(fStringToSend)
Dim RSA As System.Security.Cryptography.RSACryptoServiceProvider = New System.Security.Cryptography.RSACryptoServiceProvider(1024)
RSA.FromXmlString(strPublicKey)
Dim strEncryptedStringToSend As String = Convert.ToBase64String(RSA.Encrypt(byStringToSend, False))
Label1.Text = strEncryptedStringToSend
End Sub
End Class
And here are examples of the encrypted strings:
.net:
JNG3rMmqZkzWXwIIOLVCa2e3vTV2doPEKiSyxBFtgYEbnKpkkCKiri7Vdkovn+2T+ArPuVzgTpPEelWN/3gBtvTxSQ4Vt1+H4MMUjFcCwkYoom1V2FyzIBIZ0eqjNQfqos9F10FIQ3NkqiDCDoNHKA5yNfPLBeNQfB5C/bCzCffE6hgHqc7+zkc651V9WSBTuZq7KzgHFUmYHB+juLuZxZGt
javascript:
UGjvEQy5ZFSDJt/SKL/39giZP7iYqlR3u3f6P5FpCf/z5p/lnIIyhSNNoSOwKQspPajbczO9DxSFElKKmQSEH9keQrhj4DtcSyPMHInFWra13/fWK9VA5XiktEc2vb9XUQVeZ7DS19ZDYVq7cpA9vApiYztSMClS8CCMuatO0Gs=
To achieve interoperability with .NET I managed to give a twist to JSEncrypt and fix paddings. I also added PrivateKey encryption for JS possibility.
You can read here Decrypting RSA with JavaScript someone that used my version of JSEncrypt.

Dynamically adding meta title and description to views in .net core

I am looking for a function to add meta title and description when I enter and call values ​​in view at .net core. I have tried the following code but it did not.How do I include HtmlMeta and Page? Does this code work for me? I am waiting for your help.
protected void Page_Load(object sender, EventArgs e)
{
Page.Title = "Your Page Title";
HtmlMeta metaDescription = new HtmlMeta();
metaDescription.Name = "description";
metaDescription.Content = "Your Page Description";
Page.Header.Controls.Add(metaDescription);
HtmlMeta metaKeywords = new HtmlMeta();
metaKeywords.Name = "keywords";
metaKeywords.Content = "Your Page Keywords";
Page.Header.Controls.Add(metaKeywords);
}
In the layout page add new section inside <head> tags:
<head>
...
#await RenderSectionAsync("Header", required: false)
</head>
Then you can add meta tags to the header section from any view:
#section Header {
<meta name="description" content="#Model.Description"/>
<meta name="keywords" content="Model.KeyWords"/>
}
In your page model you can provide the values for Description and KeyWords then pass it to the view.

Multiple Outputs From One Set of Labels

I am building a website in ASP.NET Web Forms with a SQL Database. The database contains a table with 571 entry's of data.
Output
Source Code
using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
{
using (SqlCommand command = new SqlCommand("SELECT Id, Name, Townland, Near, Status, Built FROM Houses ORDER BY Name DESC", connection))
{
connection.Open();
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
lblId.Text = reader[0].ToString();
lblName.Text = reader[1].ToString();
lblTown.Text = reader[2].ToString();
lblNear.Text = reader[3].ToString();
lblStatus.Text = reader[4].ToString();
lblBuilt.Text = reader[5].ToString();
}
}
}
}
Database
I want to display all 571 houses to do this I would need a set of labels for each house but is there a way I could have one set of labels like the above code to output all 571 entry's without repeating code.
Try to use a Repeater. This is a special control, which allows to define an inner item layout only once and then bind some data to render multiple blocks looking consistently, but containing the different data.
Repeater has ItemTempalte property, which allows you to wrap all the labels you want to see.
<asp:Repeater ID="rptData" runat="server">
<ItemTemplate>
<asp:Label runat="server" Text='<%# Eval("Id") %>'></asp:Label>
<asp:Label runat="server" Text='<%# Eval("Name") %>'></asp:Label>
</ItemTemplate>
</asp:Repeater>
Then just load the DB rows into repeater:
rptData.DataSource = command.ExecuteReader();
rptData.DataBind();
And finally, in the HTML layout specify mapping for labels to respective columns - like
<asp:Label runat="server" Text='<%# Eval("Name") %>'></asp:Label>
or
<asp:Label runat="server" Text='<%# Eval("Townland") %>'></asp:Label>
etc.

ASP.Net DropDownList Retains Value From Database - AutoPostBack

I have been stuck in this problem for along time, searched online but no solution yet solved my problem. I have a dropdownlist where it retrieved the plan names from a table in my databse based on the zip code that is entered in a text field. The problem I am running into is: when I enter a zip code, the plan names populate with no problem in the dropdownlist, then I select one of the plans, when I go further and try to enter other info in other fields which have autppostback = true, the dropdownlist does not retain its value and always select the first value, I want the dropdownlist to retain the selected value after the postback, here is my code:
step1.aspx
<p>
<asp:TextBox ID="txt_zip_code" runat="server" AutoPostBack="true"></asp:TextBox>
</p>
<p>
<asp:DropDownList ID="dd_dental_plan" runat="server" EnableViewState="true">
</asp:DropDownList>
</p>
step1.cs
protected void Page_Load(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CustomerDataConnectionString"].ConnectionString))
{
using (SqlCommand sqlCmd = new SqlCommand())
{
sqlCmd.CommandText = "SELECT * FROM [dbo].[mfd_plans] WHERE zip_code = #zipCode";
sqlCmd.Parameters.AddWithValue("#zipCode", txt_zip_code.Text);
sqlCmd.Connection = conn;
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(sqlCmd);
DataTable dt = new DataTable();
da.Fill(dt);
dd_dental_plan.DataSource = dt;
dd_dental_plan.DataValueField = "plan_id";
dd_dental_plan.DataTextField = "plan_name";
dd_dental_plan.DataBind();
conn.Close();
dd_dental_plan.Items.Insert(0, new ListItem("Please select plan", "0"));
}
}
you should use update panel on your aspx page for preventing whole page load when autopostback occurs from another fields.
just put an asp:scriptmanager control on your page. After the put your zip code and dropdownlist into update panel and put other controls in separate update panels by which post back occurs. your code will look like this.
<asp:ScriptManager runat="server">
</asp:ScriptManager>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<p>
<asp:TextBox ID="txt_zip_code" runat="server" AutoPostBack="true"></asp:TextBox>
</p>
<p>
<asp:DropDownList ID="dd_dental_plan" runat="server" EnableViewState="true">
</asp:DropDownList>
</p>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
another controls which caused postback event
</ContentTemplate>
</asp:UpdatePanel>
another controls which don't cause postback.
</div>
Hope this will works.enter code here
Thanks
Umm I really hoped that I understand your Question correctly ..
Have you tried something like
if (!Page.IsPostBack)
{// All the code that you've written above ..}
and do that with all you're codes that you write in Page_Load ...
give it a try ...

VB - Convert Web Site to Web Application

This is my first time doing VB :-) I've inherited a web site, which I've converted into a web application in VS2008. The conversion has worked for everything except a Gallery control.
The compile error I'm getting is:
Type 'Gallery' is not defined in file: gallery_oct07.aspx.designer.vb
Option Strict On
Option Explicit On
Partial Public Class gallery_oct07
'''<summary>
'''Gallery1 control.
'''</summary>
'''<remarks>
'''Auto-generated field.
'''To modify move field declaration from designer file to code-behind file.
'''</remarks>
Protected WithEvents Gallery1 As Global.Gallery
End Class
with squiggly lines under Global.Gallery.
The gallery_oct07.aspx.vb is:
Partial Class gallery_oct07
Inherits System.Web.UI.Page
End Class
And the gallery_oct07.aspx file:
<%# page language="VB" masterpagefile="~/MasterPage.master" autoeventwireup="false" inherits="WebApplication1.gallery_oct07" title="2007 Trip Photos" Codebehind="~/gallery_oct07.aspx.vb" %>
<%# Register Src="Gallery.ascx" TagName="Gallery" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<script language="javascript" type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script language="javascript" type="text/javascript" src="js/thickbox.js"></script>
<p class="title">
Koru Care Christchurch Charitable Trust</p>
<img src="images/green_space.gif" />
<p class="title">
Trip Photos</p>
<p class="subTitle">
Los Angeles 2007</p>
<p class="text">
Click for larger Image</p>
<uc1:Gallery ID="Gallery1" runat="server" ImageFolder="images/oct2007/" />
</asp:Content>
Gallery.ascx is:
<%# Control Language="C#" AutoEventWireup="true" Codebehind="Gallery.ascx.cs" Inherits="WebApplication1.Gallery"%>
<asp:Repeater runat="server" ID="rptGallery">
<HeaderTemplate>
<ul class='<%#CssClass%>'>
</HeaderTemplate>
<ItemTemplate>
<li><img src='<%#ImageFolder + "thumb/" + Eval("Name") %>' /></li>
</ItemTemplate>
<FooterTemplate>
</ul></FooterTemplate>
</asp:Repeater>
and the code behind is:
using System;
using System.IO;
namespace WebApplication1
{
public partial class Gallery : System.Web.UI.UserControl
{
public string _ImageFolder;
public string ImageFolder
{
get
{
return _ImageFolder;
}
set
{
_ImageFolder = value;
}
}
private string _cssClass = "gallery";
public string CssClass
{
get
{
return _cssClass;
}
set
{
_cssClass = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
DirectoryInfo dir = new DirectoryInfo(MapPath(ImageFolder));
FileInfo[] images = dir.GetFiles("*.jpg");
rptGallery.DataSource = images;
rptGallery.DataBind();
}
protected void Page_PreRender(object sender, EventArgs e)
{
}
}
}
The feels like a namespace issue.. My project namespace is WebApplication1.
Cheers!
It seems like the code for the Gallery isn't being found, which means it's either not getting build, or has a namespace that isn't what you're expecting.
Download reflector, open up the DLL, and see if you can figure out where the control lives, namespace wise.
Other things to check:
does your project have any global namespace or DLL settings that might change things?
are you sure the build action for the control is the correct one? (i.e. make sure it's not being ignored, or included as content)
Try first to simply change from Global.Gallery to Global.WebApplication1.Gallery.
Open the "Object Browser", and change the "Object Browser Settings" to "View Containers", then browse your project's namespaces. This should help you resolve the problem.
Replace
Protected WithEvents Gallery1 As Global.Gallery
With
Protected WithEvents Gallery1 As Gallery