Hi
I am new to VB - and this seems to work in C# - so can someone help me please because thisa is driving me mad.
I have created a function as a namespace within a VB class file in my .NET project (Content) as follows:
I use the import statement in the main calling class:
However when I try to reference Class SQLCons in this class using these statements:
I get the following compilation error:
Can anyone tell me what I'm doing wrong? As I say - this works OK in C# which is where I have lifted it from and tried to convert.
Thanks in advance.
I am new to VB - and this seems to work in C# - so can someone help me please because thisa is driving me mad.
I have created a function as a namespace within a VB class file in my .NET project (Content) as follows:
VB.NET:
Imports System
Imports System.Data.SqlClient
Namespace Connections
Public Class SQLCons
Public Function LogonManager(ByVal ProcName As String, ByVal DSTabName As String, ByVal man_uname As String, ByVal man_password As String) As DataSet
Dim con As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim SQLcom As SqlCommand = New SqlCommand(ProcName, con)
SQLcom.CommandType = CommandType.StoredProcedure
Dim DA As SqlDataAdapter = New SqlDataAdapter(SQLcom)
SQLcom.Parameters.Add("@man_uname", SqlDbType.NVarChar, 50, "man_uname").Value = man_uname
SQLcom.Parameters.Add("@man_password", SqlDbType.NVarChar, 50, "man_password").Value = man_password
SQLcom.Connection.Open()
SQLcom.ExecuteNonQuery()
SQLcom.Connection.Close()
Dim DS As DataSet = New DataSet
DA.Fill(DS, DSTabName)
Return DS
End Function
End Class
End Namespace
I use the import statement in the main calling class:
VB.NET:
Imports System.Data.SqlClient
Imports System
Imports Content.Connections
However when I try to reference Class SQLCons in this class using these statements:
VB.NET:
Dim DS As DataSet = New DataSet
DS = SQLCons.LogonManager("LogonManagers", "manager", txbxUName.Text.ToString(), txbxPword.Text.ToString())
Reference to a non-shared member requires an object reference (this refers to the reference to SQLCons.LogonManager)
Can anyone tell me what I'm doing wrong? As I say - this works OK in C# which is where I have lifted it from and tried to convert.
Thanks in advance.
Last edited by a moderator: