Solved How To Read IP address From Table (2 Viewers)

Ashfaque

Student
Local time
Today, 13:04
Joined
Sep 6, 2004
Messages
766
Hi,

My following code line connects to SQL Server from Access db.

Code:
 stConnect = "ODBC;DRIVER=SQL Server;SERVER=182.128.1.7;DATABASE=INATHR;UID=hr;PWD=mypwd"

For some security reason IP address changes every week and I have to update in this module. So what I did is, I placed additional text box at login form and from there new ID address is being saved in a local table called T_IP.

I want the IP address mentioned in table T_IP should read in the above stConnect code line when each time user logins remotely. This way I could save a lot of my time in manually changing the ID address in DSN module code should execute connection.

Can someone guide me how to to do it?

Any help shall be appreciated.

Regards,
 

Gasman

Enthusiastic Amateur
Local time
Today, 08:34
Joined
Sep 21, 2011
Messages
8,832
Just concatenate the components, as that ip address would be a string, surely?
I would have thought you would have to do that for the PWD parameter anyway? :unsure:
 

Minty

AWF VIP
Local time
Today, 08:34
Joined
Jul 26, 2013
Messages
8,760
Whilst it's not uncommon for an end-user IP address to change, a server should be somewhere where that is never an issue unless it's physically moved.

I would fix that by upgrading the site (office presumably) to getting a fixed IP.
How would a user get the new IP address if they can't connect in the first place?
If you have to send them out an updated FE you may as well send it with the new IP address and connection strings already updated.
 

Ashfaque

Student
Local time
Today, 13:04
Joined
Sep 6, 2004
Messages
766
At our remote pc, one ERP is also running and in at login form of that ERP the user know the new IP address. Therefore, the remote user know whenever new IP changes.

So I did the same in my login form user will type new IP and it will be saved in a table and I want my stConnect to read IP address from table execute the connection.
 

Ashfaque

Student
Local time
Today, 13:04
Joined
Sep 6, 2004
Messages
766
Just concatenate the components, as that ip address would be a string, surely?
I would have thought you would have to do that for the PWD parameter anyway? :unsure:
Yes...I saved in text field in tbl
 

Ashfaque

Student
Local time
Today, 13:04
Joined
Sep 6, 2004
Messages
766
I tried calling following way the saved NewIP that saved in a table.

Code:
 Dim MyNewIP As String
MyNewIP = DLookup("NewIP", "T_IP")
        stConnect = "ODBC;DRIVER=SQL Server;SERVER=MyNewIP;DATABASE=INATHR;UID=hr;PWD=hr@inat123"
Set td = CurrentDb.CreateTableDef(stLocalTableName, dbAttachSavePWD, stRemoteTableName, stConnect)
CurrentDb.TableDefs.Append td

But server dialogue appearing and MyNewIP variable is appearing in IP address box.

The error is at below line:
CurrentDb.TableDefs.Append td

I believe MyNewIP need to convert to real IP address that saved in table.

Can someone help me please..?
 

Gasman

Enthusiastic Amateur
Local time
Today, 08:34
Joined
Sep 21, 2011
Messages
8,832
Google or search here for concatenation.

I can't believe after all this time you have never used it? :(
 

Users who are viewing this thread

Top Bottom