1
votes

When I create a Designer-generated DataSet in Visual Studio, using the DB2 data provider, I am asked a question as to whether I want to store sensitive information in my ConnectionString object.

As it happens, I don't, as I want to force the users to enter their own username and password, in order to evaluate their authority to run the program.

The ConnectionString generated by Visual Studio at this point is ReadOnly.

How do I set the username and password supplied by the ConnectionString if the ConnectionString is Readonly?

I'm obviously missing something, but all of the solutions I've found online have failed in ways ranging up to the connection DLL not being found, to the connection suddenly mismatching its connection type (TCP/IP) and its communication API (SOCKETS). Error included here for the sake of incredulity:

ERROR [08001] [IBM] SQL30081N  A communication error has been 
detected. Communication protocol being used: "TCP/IP".
Communication API being used: "SOCKETS".  Location where 
the error was detected: "192.168.101.243".
Communication function detecting the error: "connect".
Protocol specific error code(s): "10061", "*", "*".  SQLSTATE=08001

Stackoverflow, I give up. What am I doing wrong?

EDIT: Apologies for framing my issue poorly. I have a working connection string in place in the software. This is in the form:

"Database=dbName;User ID=admin;Password=adminPassword;Server=192.168.101.111:1111"

This connectionString works fine, no problems, everything is good.

My problem occurs when I try to change the connectionString at runtime to:

"Database=dbName;User ID=user;Password=userPassword;Server=192.168.101.111:1111"

What I'm looking for is an answer to the question: "How do I make changes to the designer-generated connectionString at runtime?" because everything I've tried so far has evidently been wrong.

2

2 Answers

1
votes

I suggest you verify whether the NETTYPE=onsoctcp on the Informix IDS Server you're trying to access.

1
votes

Having read through the link provided by Frank Computer, I believe I have discovered the following:

I was doing the wrong thing by trying to make changes to the designer-generated ConnectionString object.

The actual answer I was looking for was that connection strings should be set on a per-tableAdapter basis in the form:

Dim x As New DataSet1_TableAdapters.myTableAdapter
x.Connection.ConnectionString = newConnectionString

The connectionString generated by the Designer is used in the Designer-generated constructor for the TableAdapters, and its existence avoids a NullReferenceException. Correct procedure (as far as I have now discovered) is to allow this incorrect connectionString to be used, and then to change it to the correct connectionString before actually trying to use the connection.

In fairness, having this ConnectionString in place serves the purpose of not breaking the designer-generated code, but is otherwise, as I say, basically a trap designed to make you start solving the wrong problem if you need to make changes to the connection string.