Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2002
    Posts
    15

    Question Unanswered: Host_name from Visual Basic

    HI,

    I have a storage procedure that use host_name(), but when this procedure executes from VB the function host_name return Null.
    But when this procedure executes from SQL Advantage the function host_name return host computer name of the client process.

    Check at look:
    create proc_audit (param1 ... , param2...)
    as
    declare @stationname varchar(30)
    select @stationname = host_name()

    insert into sipaudit
    (field1, field2,.., fieldn)
    values
    (param1,param2,..., @stationname)
    go

    Why that happens?

  2. #2
    Join Date
    Sep 2003
    Location
    London
    Posts
    12

    Re: Host_name from Visual Basic

    The host_name() funtion only works when the client application supplies a host name during login. SQL Advantage does this & isql does it, but clearly VB doesnt (and something called sqsh doesn't either). There may be a way of making it do it, but I wouldn't know how I'm afraid.
    Will

  3. #3
    Join Date
    Jun 2003
    Location
    Sydney, Australia
    Posts
    66

    Re: Host_name from Visual Basic

    Depends on the OleDb provider you are using. If it is just a bridge to ODBC, then I'm not sure how would it work. But if it is AdoDb Version 2.7 from Sybase, then you can pass the WorkstationID parameter in the connection string.

    Perhaps something like:

    Dim cn As ADODB.Connection, cs as String

    Set cn = New ADODB.Connection
    cn.Provider = "Sybase.ASEOLEDBProvider"

    cs = "Data Source=svr;User ID=x;WorkstationID=<host>"
    cn.ConnectionString = cs
    cn.Open

    If the WorkstationID parameter is not accepted, try it with a blank before ID, similar to User ID.

    The next question will how do you get the <host>. In other words, how would your VB code know what is the machine name it is running on. If there is no builting function, you may try a kernel call, something like GetSystemNameA (not sure). Or, perhaps you have an environment variable.

    Andrew

  4. #4
    Join Date
    Mar 2002
    Posts
    15

    Red face Re: Host_name from Visual Basic

    Hi,
    I look the conetion's properties, are:
    OLE DB Services
    Initial Catalog
    Connect Timeout
    Extended Properties
    Prompt
    Mode
    Locale Identifier
    Window Handle
    Data Source
    User ID
    Persist Security Info
    Password

    and does not exist Workstation ID.

    I'm using the Provider=Sybase.ASEOLEDBProvider.2. You other idea.



    Originally posted by andrewsc
    Depends on the OleDb provider you are using. If it is just a bridge to ODBC, then I'm not sure how would it work. But if it is AdoDb Version 2.7 from Sybase, then you can pass the WorkstationID parameter in the connection string.

    Perhaps something like:

    Dim cn As ADODB.Connection, cs as String

    Set cn = New ADODB.Connection
    cn.Provider = "Sybase.ASEOLEDBProvider"

    cs = "Data Source=svr;User ID=x;WorkstationID=<host>"
    cn.ConnectionString = cs
    cn.Open

    If the WorkstationID parameter is not accepted, try it with a blank before ID, similar to User ID.

    The next question will how do you get the <host>. In other words, how would your VB code know what is the machine name it is running on. If there is no builting function, you may try a kernel call, something like GetSystemNameA (not sure). Or, perhaps you have an environment variable.

    Andrew

Posting Permissions

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