本文介绍了c急剧到vb.net代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,如果我使用的是vb.net代码使用的代码而不是:

Dears if i am using vb.net what the code using instead of this:

using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.ApplicationBlocks.Data;
using Microsoft.Reporting.WebForms;

public partial class ReportViewerLocalMode : System.Web.UI.Page
{
    public string thisConnectionString = 
       ConfigurationManager.ConnectionStrings[
       "NorthwindConnectionString"].ConnectionString;

    /*I used the following statement to show if you have multiple 
      input parameters, declare the parameter with the number 
      of parameters in your application, ex. New SqlParameter[4]; */

    public SqlParameter[] SearchValue = new SqlParameter[1];

    protected void RunReportButton_Click(object sender, EventArgs e)
    {
        //ReportViewer1.Visible is set to false in design mode
        ReportViewer1.Visible = true;
        SqlConnection thisConnection = new SqlConnection(thisConnectionString);
        System.Data.DataSet thisDataSet = new System.Data.DataSet();       
        SearchValue[0] = new SqlParameter("@CategoryName", 
                         DropDownList1.SelectedValue);

        /* Put the stored procedure result into a dataset */
        thisDataSet = SqlHelper.ExecuteDataset(thisConnection, 
                      "ShowProductByCategory", SearchValue);

        /*or   thisDataSet = SqlHelper.ExecuteDataset(thisConnection, 
               "ShowProductByCategory", dropdownlist1.selectedvalue); 
               if you only have 1 input parameter  */

        /* Associate thisDataSet  (now loaded with the stored 
           procedure result) with the  ReportViewer datasource */
        ReportDataSource datasource = new 
          ReportDataSource("DataSetProducts_ShowProductByCategory", 
          thisDataSet.Tables[0]);

        ReportViewer1.LocalReport.DataSources.Clear();
        ReportViewer1.LocalReport.DataSources.Add(datasource);
        if (thisDataSet.Tables[0].Rows.Count == 0)
        {
            lblMessage.Text = "Sorry, no products under this category!";
        }

        ReportViewer1.LocalReport.Refresh();
    }
}



i在sqlhelper上出错了

我使用的是Microsoft.ApplicationBlocks.Data但它'也没定义并给出错误

谢谢


i got a error on sqlhelper
and i put using Microsoft.ApplicationBlocks.Data but it''s not define and give error also
thank you

推荐答案


Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports Microsoft.ApplicationBlocks.Data
Imports Microsoft.Reporting.WebForms

Public Partial Class ReportViewerLocalMode
	Inherits System.Web.UI.Page
	Public thisConnectionString As String = ConfigurationManager.ConnectionStrings("NorthwindConnectionString").ConnectionString

	'I used the following statement to show if you have multiple 
'      input parameters, declare the parameter with the number 
'      of parameters in your application, ex. New SqlParameter[4]; 


	Public SearchValue As SqlParameter() = New SqlParameter(0) {}

	Protected Sub RunReportButton_Click(sender As Object, e As EventArgs)
		'ReportViewer1.Visible is set to false in design mode
		ReportViewer1.Visible = True
		Dim thisConnection As New SqlConnection(thisConnectionString)
		Dim thisDataSet As New System.Data.DataSet()
		SearchValue(0) = New SqlParameter("@CategoryName", DropDownList1.SelectedValue)

		' Put the stored procedure result into a dataset 

		thisDataSet = SqlHelper.ExecuteDataset(thisConnection, "ShowProductByCategory", SearchValue)

		'or   thisDataSet = SqlHelper.ExecuteDataset(thisConnection, 
'               "ShowProductByCategory", dropdownlist1.selectedvalue); 
'               if you only have 1 input parameter  


		' Associate thisDataSet  (now loaded with the stored 
'           procedure result) with the  ReportViewer datasource 

		Dim datasource As New ReportDataSource("DataSetProducts_ShowProductByCategory", thisDataSet.Tables(0))

		ReportViewer1.LocalReport.DataSources.Clear()
		ReportViewer1.LocalReport.DataSources.Add(datasource)
		If thisDataSet.Tables(0).Rows.Count = 0 Then
			lblMessage.Text = "Sorry, no products under this category!"
		End If

		ReportViewer1.LocalReport.Refresh()
	End Sub
End Class


Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports Microsoft.ApplicationBlocks.Data
Imports Microsoft.Reporting.WebForms

Partial Public Class Report
    Inherits System.Web.UI.Page
    Public thisConnectionString As String = ConfigurationManager.ConnectionStrings("NorthwindConnectionString").ConnectionString

    'I used the following statement to show if you have multiple 
    '      input parameters, declare the parameter with the number 
    '      of parameters in your application, ex. New SqlParameter[4]; 


    Public SearchValue As SqlParameter() = New SqlParameter(0) {}

    Protected Sub RunReportButton_Click(ByVal sender As Object, ByVal e As EventArgs)
        'ReportViewer1.Visible is set to false in design mode
        ReportViewer1.Visible = True
        Dim thisConnection As New SqlConnection(thisConnectionString)
        Dim thisDataSet As New System.Data.DataSet()
        SearchValue(0) = New SqlParameter("@CategoryName", DropDownList1.SelectedValue)

        ' Put the stored procedure result into a dataset 

        thisDataSet = SqlHelper.ExecuteDataset(thisConnection, "ShowProductByCategory", SearchValue)

        'or   thisDataSet = SqlHelper.ExecuteDataset(thisConnection, 
        '               "ShowProductByCategory", dropdownlist1.selectedvalue); 
        '               if you only have 1 input parameter  


        ' Associate thisDataSet  (now loaded with the stored 
        '           procedure result) with the  ReportViewer datasource 

        Dim datasource As New ReportDataSource("DataSetProducts_ShowProductByCategory", thisDataSet.Tables(0))

        ReportViewer1.LocalReport.DataSources.Clear()
        ReportViewer1.LocalReport.DataSources.Add(datasource)
        If thisDataSet.Tables(0).Rows.Count = 0 Then
            lblMessage.Text = "Sorry, no products under this category!"
        End If

        ReportViewer1.LocalReport.Refresh()
    End Sub
End Class





并且还存在2个错误:

1-命名空间错误:导入Microsoft.ApplicationBlocks.Data

2- sqlhelper中的错误(sqlhelper未定义)有什么帮助吗?



and also exist 2 errors :
1- error in namespace:Imports Microsoft.ApplicationBlocks.Data
2- error in sqlhelper(sqlhelper not define) any help please ?


这篇关于c急剧到vb.net代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 04:56