Results 1 to 33 of 33

Thread: Retrieve sql server information.

  1. #1

    Thread Starter
    Addicted Member Tjoppie's Avatar
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    241

    Retrieve sql server information.

    Hi all,

    I want to insert information like SQL Server Version, current sql server user etc into a form, How will I achieve this?

    Thanks

    Rudi Groenewald

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Retrieve sql server information.

    For SQL Server Version, you can run this query against sql server:

    SELECT @@VERSION

    I am not sure what you mean by "current sql server user" and "etc"

  3. #3

    Thread Starter
    Addicted Member Tjoppie's Avatar
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    241

    Re: Retrieve sql server information.

    By current sql server user I mean the SCURRENT_USER() command. How will my code look if I wanted the version on a textbox on a windows form?

    Thanks

    Rudi

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Retrieve sql server information.

    You can use the ExecuteScalar method of the SQLConnection class that will return a single value to you in a string.

    Read:
    http://msdn.microsoft.com/library/en...calartopic.asp

  5. #5

    Thread Starter
    Addicted Member Tjoppie's Avatar
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    241

    Re: Retrieve sql server information.

    thanks

  6. #6

    Thread Starter
    Addicted Member Tjoppie's Avatar
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    241

    Unhappy Re: Retrieve sql server information.

    Please excuse my stupidity, but I'm still lost. What I wanna do is the following:

    In my application, I will refer numerous times to sql server variables and static information. So what I want to do is create a class that can give me that static information.

    One of these values I will use alot is the current user logged on at the sql server ("CURRENT_USER()" Command)

    How will I go about to create this public class to get this value, is it possible that you could give me an example?

    I've got like, a class already to specify system colors and stuff that exists out of the following:

    VB Code:
    1. Imports System.Data.SqlClient
    2.  
    3. Module JMSGlobals
    4.     Public JMSColor = Color.FromArgb(149, 178, 198)
    5.     Public JMSConnection As New SqlConnection
    6.     Public JMSColorLblsBack = Color.FromArgb(57, 106, 105)
    7.  
    8. End Module

    Is it possible to now make values like the current sql server user and sql server version available in the same class?

    One other function that I'd like to add but I don't know how is eg: I've got a table (Tbl_Employees) on sql server which is my employees master. Now to get information about the current user and make it public in that same class as above. I was thinking on using something like "select ManagerName from Tbl_employees where Login = CURRENT_USER()"

    and then make that value that's returned public. How will I do that?

    Thanks alot, I really need to get this one figured out.

    Regards,
    Rudi Groenewald

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Retrieve sql server information.

    When you say that you will refer to the information numerous times, will it be the same information? In other words, will there always be just ONE user logged in to the SQL Server database in the duration of your application run?

    If what I just asked is true, then you can create a class quite similar to your coloring class, with the difference being that you query the database in the constructor (Sub New) of your class and hold the values in Public Properties. This way you can just keep referring to the object's properties without having to requery the database continously.

    If, on the other hand, this information is dynamic, then you can make functions which return strings, instead of public properties in your class.

    (Btw, your coloring "class" isn't really a class, it is a module, I just thought I should point that out)

    So which one of the above two is it? And do you have a problem creating a class?

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Retrieve sql server information.

    Is it possible to now make values like the current sql server user and sql server version available in the same class?

    One other function that I'd like to add but I don't know how is eg: I've got a table (Tbl_Employees) on sql server which is my employees master. Now to get information about the current user and make it public in that same class as above. I was thinking on using something like "select ManagerName from Tbl_employees where Login = CURRENT_USER()"

    and then make that value that's returned public. How will I do that?
    This will be very similar to the technique you implement for the post above. However, I have to question your architecture, and as to why you're using CURRENT_USER. Pardon me if it's a little too obvious to you.

  9. #9

    Thread Starter
    Addicted Member Tjoppie's Avatar
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    241

    Re: Retrieve sql server information.

    Hi Mendhak,

    Yes ur right, There will only be one user logged in for the duration of the application's run, as the application will be open one instance per user. (will be open on numerous pc's, but only one user) so only one user will be "logged in" on my application. (Hope that makes sense)

    This information will stay static, so yes, I'll would like it to be returned as static data. Even data that I get from the "Employee Master" like the user's manager's name, user's Shift he work's on's color, that kind of stuff. This information stays static in the database, but gets inserted into tables as the user uses the application. for eg: When the user does a purchasing transaction, the current user's login name gets inserted in the table. then I would use this class / module, to insert the current username. or I would filter records in a datagrid using the current username so that the user only sees his own records.. If that makes it a bit clearer to you.

    Mostly, I would refer to the user's company employee number. so this is static aswell. I would get this value from the employees table in sql server, and refer to it each time I would filter records, insert new records into different tables, etc etc.

    Thanks alot for all the help, please ask some more questions if you need to.

  10. #10
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Retrieve sql server information.

    What you are describing is something similar to what most of us call a Data Access Layer. It is basically a class or a bunch of classes which you create to perform your database operations for you. The only thing you 'do' from your boundary class is to simply call the function or method.

    So this is a good approach that you are taking. There are of course 99 different variations you can take to this approach, but you'll have to find out which one is best for you, and you will realize that as you code.

    Now, you can start off (I'm showing you a very very basic DAL) with creating a class that represents your employee, give it some public properties like Employee Number, Manager ID, Address, Gender, Shift, Favorite Cold Drink (Default that to Mountain Dew ) and so on.

    In this class, you can create your methods and functions to perform the database operations and querying, which would also set your properties to be accessed later.

    How familiar are you with OOP?

  11. #11

    Thread Starter
    Addicted Member Tjoppie's Avatar
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    241

    Red face Re: Retrieve sql server information.

    uhhh... OOP? Sorry for the stupidity, I've only started studying mcad and mcsd last week, so please bare with me.

    Allright. How would I start this off?

    All the values, should use my connection called JMSConnection as stated in the public module JMSGlobals as so:

    VB Code:
    1. Module JMSGlobals
    2.     Public JMSColor = Color.FromArgb(149, 178, 198)
    3.     Public JMSConnection As New SqlConnection
    4.     Public JMSColorLblsBack = Color.FromArgb(57, 106, 105)
    5.  
    6. End Module

    now the connection string for that connection gets set on the login form as follows:

    VB Code:
    1. Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click
    2.  
    3.         If (RdoSQLAuth.Checked = True) Then
    4.  
    5.             JMSGlobals.JMSConnection.ConnectionString = "Data Source=" & Me.txtJMSServer.Text & ";Initial Catalog=MSTRIBOLOGY;User Id=" & Me.txtUsername.Text & ";Password=" & Me.txtPassword.Text & ";Application Name=" & Application.ProductName & " " & Application.ProductVersion & ";"
    6.             Me.DialogResult = DialogResult.OK
    7.             'Me.Close()
    8.  
    9.         ElseIf (RdoNTAuth.Checked = True) Then
    10.             JMSGlobals.JMSConnection.ConnectionString = "Data Source=" & Me.txtJMSServer.Text & ";Initial Catalog=MSTRIBOLOGY;Integrated Security=SSPI;workstation id=" & Environment.MachineName & ";Application Name=" & Application.ProductName & " " & Application.ProductVersion & ";"
    11.             Me.DialogResult = DialogResult.OK
    12.             'Me.Close()
    13.         End If
    14.  
    15.     End Sub

    Right... Now I started out my class as:

    VB Code:
    1. Class JMSServerEmployees
    2.  
    3.     Dim EmployeeID As String
    4.     Dim login As String
    5. End Class


    Great start isnt it? hehe... I'm already lost...

    I'm open for some learning...

    Thanks alot for the help thusfar.

    \\mendhak scores some more reputation points on this one... hehe

  12. #12
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Retrieve sql server information.

    1. OOP = Object Oriented Programming

    2. OK, I see where you are going with this. You want your connection object to remain visible to the entire project, in all forms.

    So far, what you have done is to create the Employee class. Fine. But your database code is in your forms, which is... not good. What you need to do is to expand this class more:

    VB Code:
    1. Class JMSServerEmployees
    2.  
    3.     Dim EmployeeID As String
    4.     Dim login As String
    5.  
    6.  
    7. Public Function DoDatabaseLogin(ByVal strServerName As String, ByVal strUserName As String, ByVal strPassword As String, ByVal NtAuth As Boolean) As DialogResult
    8.  
    9. If NtAuth Then
    10. JMSGlobals.JMSConnection.ConnectionString = "Data Source=" & strServerName  & ";Initial Catalog=MSTRIBOLOGY;User Id=" & strUserName & ";Password=" & strPassword & ";Application Name=" & Application.ProductName & " " & Application.ProductVersion & ";"
    11.             Return DialogResult.OK
    12.  
    13. Else
    14.   JMSGlobals.JMSConnection.ConnectionString = "Data Source=" & Me.txtJMSServer.Text & ";Initial Catalog=MSTRIBOLOGY;Integrated Security=SSPI;workstation id=" & Environment.MachineName & ";Application Name=" & Application.ProductName & " " & Application.ProductVersion & ";"
    15.             Return DialogResult.OK
    16. End If
    17.  
    18. End Function
    19.  
    20. End Class

    I haven't edited all the code above, btw, that's for you to do...

    Then you can call this function from the login button click:

    VB Code:
    1. Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click
    2.  
    3.         If (RdoSQLAuth.Checked = True) Then
    4. MyEmpObj.DoDataBaseLogin(Me.txtUserName.Text, Me.txtPassword.Text.... blah blah)
    5.         ElseIf (RdoNTAuth.Checked = True) Then
    6.         End If
    7.  
    8.     End Sub

  13. #13

    Thread Starter
    Addicted Member Tjoppie's Avatar
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    241

    Re: Retrieve sql server information.

    1. Aah ok I see, Oop... Why didn't I think of that.
    2. Yup, want the connection string public, cause there's gonna be alotta forms, and some users login via sql server authentication and some via nt authentication.

    I'm trying that code you've given me now... will get back in a sec. How would I do that class on the sql server variables?

    Thanks for all the help thusfar. I battled a bit this morning cause I added more projects to my solution, (class library for all my forms) so that I don't end up with a 10 mb exe file.

  14. #14
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Retrieve sql server information.

    SQL Server Variables? Care to explain?

    Oh, and to add to your confusion, store your connection string in the application .CONFIG file.

  15. #15

    Thread Starter
    Addicted Member Tjoppie's Avatar
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    241

    Re: Retrieve sql server information.

    lol... Yeah , that kinda get me over the edge of confusion. How would I save it in the config file?

    Sql Server variables: The informatin that I wanted in the beginning, like the current username, The favourite pet name, mountain dew soft drink, shift color... that stuff.

    btw, this is how far I've gotten now.

    My class's name I've given where I will put all my classes and modules and functions and stuff that's got to do is called ServerOperations.

    VB Code:
    1. Public Class ServerOperations
    2.     Public Function DoDatabaseLogin(ByVal strServerName As String, ByVal strUserName As String, ByVal strPassword As String, ByVal NtAuth As Boolean) As DialogResult
    3.  
    4.         If NtAuth = False Then
    5.             JMSGlobals.JMSConnection.ConnectionString = "Data Source=" & strServerName & ";Initial Catalog=MSTRIBOLOGY;User Id=" & strUserName & ";Password=" & strPassword & ";Application Name=" & Application.ProductName & " " & Application.ProductVersion & ";"
    6.             Return DialogResult.OK
    7.  
    8.         Else
    9.             JMSGlobals.JMSConnection.ConnectionString = "Data Source=" & strServerName & ";Initial Catalog=MSTRIBOLOGY;Integrated Security=SSPI;workstation id=" & Environment.MachineName & ";Application Name=" & Application.ProductName & " " & Application.ProductVersion & ";"
    10.             Return DialogResult.OK
    11.         End If
    12.  
    13.     End Function
    14.  
    15. End Class

    Now on the click event of my login form's Login Button I've changed the code to this:

    VB Code:
    1. Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click
    2.         Dim LoginOp As New Object
    3.  
    4.         Try
    5.             If (RdoSQLAuth.Checked = True) Then
    6.                 LoginOp.DoDatabaseLogin(Me.txtJMSServer, Me.txtUsername, Me.txtPassword, False)
    7.                 Me.DialogResult = DialogResult.OK
    8.  
    9.             ElseIf (RdoNTAuth.Checked = True) Then
    10.                 LoginOp.DoDatabaseLogin(Me.txtJMSServer, , , False)
    11.                 Me.DialogResult = DialogResult.OK
    12.             End If
    13.  
    14.         Catch ex As Exception
    15.  
    16.         End Try
    17.  
    18.     End Sub

    And just guess what.... Nothing happens when I click on the button now... grr... any ideas?

    Thanks

    Rudi

  16. #16
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Retrieve sql server information.

    Dim LoginOp As New Object

    should be

    Dim LoginOp As New ServerOperations

  17. #17

    Thread Starter
    Addicted Member Tjoppie's Avatar
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    241

    Re: Retrieve sql server information.

    oooooh... I c...doh..I feel so sheepish.

    Ok... Roit. I've got that now.... the config thingy? and now we can move on to the sql server values?

    Thanks for all the help thusfar... You're helping alot!

    Rudi

  18. #18
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Retrieve sql server information.

    In the application config file, add this:

    <add key="MyConnectionString" value="Yourconnectionstring blah blah" />

    And in your code, wherever you want to retrieve the value, use:

    System.Configuration.COnfigurationSettings.AppSettings("MyConnectionString")

  19. #19

    Thread Starter
    Addicted Member Tjoppie's Avatar
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    241

    Re: Retrieve sql server information.

    Ah ok, Thanks, I got that.

    Now.... How would I go to work to retrieve information from sql server?

    Thanks
    Rudi

  20. #20
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Retrieve sql server information.

    Do you know any ADO.NET?

  21. #21

    Thread Starter
    Addicted Member Tjoppie's Avatar
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    241

    Re: Retrieve sql server information.

    A little bit, but I'm sure if I get a few hints, I'll be able to manage. I used ado in ms access... but that's about it.

  22. #22
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Retrieve sql server information.


  23. #23

    Thread Starter
    Addicted Member Tjoppie's Avatar
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    241

    Re: Retrieve sql server information.

    Ok... I'm looking through that now...ummm yeah...

    Yeah, I'm looking through it now.
    Hmmm... yeah... looks good yeah....

  24. #24
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Retrieve sql server information.

    Take your time. It'll be very useful for all your future apps. Well, most of them anyways. Post again when you get stuck somewhere.

  25. #25

    Thread Starter
    Addicted Member Tjoppie's Avatar
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    241

    Re: Retrieve sql server information.

    Hi Mendhak....

    Last night I tried to get only the current username from sql server, but failed miserably. Could you give me an example of how to get something from the server into that class I'm trying?

    Thanks
    Rudi

  26. #26
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Retrieve sql server information.

    Show your code!

    Did you use a statement like this?

    Code:
    SELECT CONVERT(CHAR (30), CURRENT_USER) AS CurrentUserName

  27. #27

    Thread Starter
    Addicted Member Tjoppie's Avatar
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    241

    Re: Retrieve sql server information.

    Hi Mendhak,

    This is my class which I want to retrieve my values from:

    VB Code:
    1. Imports System.Data.SqlClient
    2. Imports System.Drawing
    3.  
    4. Public Module JMSGlobals
    5.     Public JMSColor = Color.FromArgb(149, 178, 198)
    6.     Public JMSConnection As New SqlConnection
    7.     Public JMSColorLblsBack = Color.FromArgb(57, 106, 105)
    8.  
    9.     Public Function CurrentUserName()
    10.         Dim myDataReader As SqlDataReader
    11.         Dim CurrentSQLUser As SqlCommand
    12.  
    13.  
    14.         JMSConnection = JMSClasses.JMSConnection
    15.         JMSConnection.ConnectionString = JMSClasses.JMSConnection.ConnectionString
    16.         CurrentSQLUser = New SqlCommand("SELECT CONVERT(CHAR (30), CURRENT_USER) AS CurrentUserName", JMSConnection)
    17.         JMSConnection.Open()
    18.         myDataReader = CurrentSQLUser.ExecuteReader(CommandBehavior.CloseConnection)
    19.     End Function
    20. End Module

    It's called JMSGlobals.vb

    This is how I referred to this code:

    VB Code:
    1. Private Sub FrmMenu_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.                Me.lblWelcomeName.Text = JMSClasses.CurrentUserName

    What am I doing wrong?

    Thanks
    Rudi

  28. #28
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Retrieve sql server information.

    Don't use ExecuteReader. Use ExecuteScalar.

    Also, in your function CurrentUserName, you need to specify a return type (string) and a return value.

  29. #29

    Thread Starter
    Addicted Member Tjoppie's Avatar
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    241

    Re: Retrieve sql server information.

    I get index out of range exception when I changed my code to the following:

    VB Code:
    1. Imports System.Data.SqlClient
    2. Imports System.Drawing
    3.  
    4. Public Module JMSGlobals
    5.     Public JMSColor = Color.FromArgb(149, 178, 198)
    6.     Public JMSConnection As New SqlConnection
    7.     Public JMSColorLblsBack = Color.FromArgb(57, 106, 105)
    8.  
    9.     Public Function CurrentUserName()
    10.         Dim myDataReader As SqlDataReader
    11.         Dim RetrieveSQLUser As SqlCommand
    12.         Dim CurrentSQLUser As String
    13.  
    14.         JMSConnection = JMSClasses.JMSConnection
    15.         JMSConnection.ConnectionString = JMSClasses.JMSConnection.ConnectionString
    16.         RetrieveSQLUser = New SqlCommand("SELECT CONVERT(CHAR (30), CURRENT_USER) AS CurrentUserName", JMSConnection)
    17.         JMSConnection.Open()
    18.         myDataReader = RetrieveSQLUser.ExecuteScalar(CommandBehavior.CloseConnection)
    19.         CurrentSQLUser = myDataReader.Read
    20.     End Function
    21. End Module

  30. #30

    Thread Starter
    Addicted Member Tjoppie's Avatar
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    241

    Re: Retrieve sql server information.

    Anyone have any idea? I know I've almost got it. If I can just get this datareader to work......... puh puh puh puh puh please

  31. #31

    Thread Starter
    Addicted Member Tjoppie's Avatar
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    241

    Re: Retrieve sql server information.

    Hey,

    Ok... I've done the following, but I have the following questions:

    VB Code:
    1. Public Function CurrentUserName()
    2.             Try
    3.                 Dim myDataReader As SqlDataReader
    4.                 Dim RetrieveSQLUser As SqlCommand
    5.                 Dim CurrentSQLUser As String
    6.  
    7.                 JMSConnection = JMSClasses.JMSGlobals.JMSConnection
    8.                 JMSConnection.ConnectionString = JMSClasses.JMSGlobals.JMSConnection.ConnectionString
    9.                 RetrieveSQLUser.CommandText = "Select SUSER_SNAME() AS SQLLogin"
    10.                 JMSConnection.Open()
    11.                 RetrieveSQLUser.ExecuteScalar()
    12.                 JMSConnection.Close()
    13.             Catch ex As Exception
    14.                 MsgBox(ex.ToString)
    15.             End Try
    16.  
    17.  
    18.         End Function

    When running this code, I get like, a msgbox with nothing in it... and the value isnt displayed on the form.

    #1: How do I specify the return type and return value?
    #2: What am I doing wrong in my code?

    Thanks

    Rudi

  32. #32

    Thread Starter
    Addicted Member Tjoppie's Avatar
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    241

    Unhappy Re: Retrieve sql server information.

    Hi all,

    Ok I never thought it would get down to this, but now I'm begging:
    I changed my code to the following, but still no luck:

    VB Code:
    1. Imports System.Data.SqlClient
    2. Imports System.Drawing
    3. Namespace JMSGlobals
    4.     Public Module JMSGlobals
    5.         Public JMSColor = Color.FromArgb(149, 178, 198)
    6.         Public JMSConnection As New SqlConnection
    7.         Public JMSColorLblsBack = Color.FromArgb(57, 106, 105)
    8.  
    9.         Public Function CurrentUserName()
    10.             Try
    11.                 Dim myDataReader As SqlDataReader
    12.                 Dim RetrieveSQLUser As New SqlCommand
    13.                 Dim CurrentSQLUser As String
    14.                 Dim SQLString As String
    15.                 Dim JMSConnection As New SqlConnection
    16.                 SQLString = "Select SUSER_SNAME() As SQLLogin"
    17.  
    18.                 RetrieveSQLUser.Connection = JMSClasses.JMSGlobals.JMSConnection
    19.                 RetrieveSQLUser.Connection.Open()
    20.                 RetrieveSQLUser.CommandText = SQLString
    21.                 RetrieveSQLUser.ExecuteScalar().ToString()
    22.                 RetrieveSQLUser.Connection.Close()
    23.             Catch ex As Exception
    24.                 MsgBox(ex.ToString)
    25.             End Try
    26.         End Function
    27.     End Module
    28. End Namespace

    I still can't get the value to get retrieved. The application runs like normal, but nothing happens (the value isnt inserted in the label)

    Please Help!

  33. #33

    Thread Starter
    Addicted Member Tjoppie's Avatar
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    241

    Re: Retrieve sql server information.

    Hi all,

    Ok This is mind boggling...

    I took the code that I've got in my class I'm creating. Pasted that in the form's code, referred to that to show in the label's text value, call the function on the form's load event......... and it works... it retrieves the value.

    now WHY OH WHY, does it work when the codes' inside the form, but when I refer to a publically available class, it doesn't get the value......

    Someone PLEASE help me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width