nehaperiyasamy Ответов: 1

Я должен создать кодировку, которая есть VB.NET там не было никакого сообщения об ошибке, но он показывает мне предупреждающее сообщение


то что меня поместили сюда с предупреждающим сообщением

Imports System.Data.OleDb


Namespace attendance

Partial Class attendinputadmin
        Inherits System.Web.UI.Page
        Protected WithEvents button1 As System.Web.UI.WebControls.Button
        Protected WithEvents button2 As System.Web.UI.WebControls.Button
        Protected WithEvents radiobuttonlist1 As System.Web.UI.WebControls.RadioButtonList
        Protected WithEvents radiobuttonlist2 As System.Web.UI.WebControls.RadioButtonList
        Protected WithEvents radiobuttonlist3 As System.Web.UI.WebControls.RadioButtonList
        Protected WithEvents radiobuttonlist4 As System.Web.UI.WebControls.RadioButtonList
        Protected WithEvents radiobuttonlist5 As System.Web.UI.WebControls.RadioButtonList
    Protected WithEvents OleDbConnection1 As System.Data.OleDb.OleDbConnection

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.OleDbConnection1 = New System.Data.OleDb.OleDbConnection()
        '
        'OleDbConnection1
        '
            Me.OleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=E:\project" & _
        "\attend.mdb;Mode=Share Deny None;Extended Properties="""";Jet OLEDB:System databas" & _
        "e="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine " & _
        "Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet" & _
        " OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:C" & _
        "reate System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Cop" & _
        "y Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLE" & _
        "DB:SFP=False"

    End Sub

    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
        'Put user code to initialize the page here
            Button1.Visible = False
            RadioButtonList1.Visible = False

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Button1.Visible = False
        Application("year") = RadioButtonList1.SelectedItem.Text
        Application("branch") = RadioButtonList2.SelectedItem.Text
        Application("section") = RadioButtonList3.SelectedItem.Text
        Application("semester") = RadioButtonList4.SelectedItem.Text

        Dim str As String
        str = "select subcode,subdesc from submaster where year=@year and branch=@branch and sem=@sem"

        Dim cmd1 As OleDbCommand
        cmd1 = New OleDbCommand(str, OleDbConnection1)
        cmd1.Parameters.Add("@year", Application("year"))(HERE I GOT THE WARNING MESSAGE Warning	1	'Public Function Add(parameterName As String, value As Object) As System.Data.OleDb.OleDbParameter' is obsolete: 'Add(String parameterName, Object value) has been deprecated.  Use AddWithValue(String parameterName, Object value).  http://go.microsoft.com/fwlink/?linkid=14202'.	C:\Users\suresh\Documents\Visual Studio 2010\Projects\project\project\attendinputadmin.aspx.vb	63	9	project)

        cmd1.Parameters.Add("@branch", Application("branch"))
        cmd1.Parameters.Add("@sem", Application("semester"))

        cmd1.Connection.Open()
        Dim reader As OleDbDataReader = cmd1.ExecuteReader()
        Dim r As String
        While reader.Read()
            r = reader.GetValue(1) & "(" & reader.GetValue(0) & ")"
            RadioButtonList5.Items.Add(r)
        End While
        cmd1.Connection.Close()

        Button2.Visible = True
        RadioButtonList5.Visible = True

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim st As String
        st = RadioButtonList5.SelectedItem.Text
        Application("subcode") = st.Substring(st.IndexOf("(") + 1, 6)
        Response.Redirect("entryinput.aspx")
        
    End Sub
End Class

End Namespace


Что я уже пробовал:

Warning	1	'Public Function Add(parameterName As String, value As Object) As System.Data.OleDb.OleDbParameter' is obsolete: 'Add(String parameterName, Object value) has been deprecated.  Use AddWithValue(String parameterName, Object value).  http://go.microsoft.com/fwlink/?linkid=14202'.	C:\Users\suresh\Documents\Visual Studio 2010\Projects\project\project\attendinputadmin.aspx.vb	63	9	project

1 Ответов

Рейтинг:
7

Patrice T

Чтобы исправить предупреждение, прочтите сообщение !
Предупреждение таково:

Warning	1	'Public Function Add(parameterName As String, value As Object) As System.Data.OleDb.OleDbParameter' is obsolete: 'Add(String parameterName, Object value) has been deprecated.  Use AddWithValue(String parameterName, Object value).

Причина в следующем:
Warning	1	'Public Function Add(parameterName As String, value As Object) As System.Data.OleDb.OleDbParameter' is obsolete: 'Add(String parameterName, Object value) has been deprecated.  Use AddWithValue(String parameterName, Object value).

Решение таково:
Warning	1	'Public Function Add(parameterName As String, value As Object) As System.Data.OleDb.OleDbParameter' is obsolete: 'Add(String parameterName, Object value) has been deprecated.  Use AddWithValue(String parameterName, Object value).

Просто нужно прочитать документацию для получения более подробной информации.