none
Changing password in connection sting RRS feed

  • Question

  •  

    I posted this in the VB forum, but this is clearly a better place. Sorry for the duplicate post.

     

    Anyway, I have a web page that accesses an AS400 database. Everything works fine with a hard-coded connection string either in the page or the web.config file.  Unfortunately, I have to change the password on a regular basis and cannot seem to get the string to work using text from two text boxes (for uid and pwd).  I get an error message saying the "Format of the initialization string does not conform to the specification starting at index 0."  This even happens when I define the variable with the exact wording of the connection string ("Dsn=njc_crfiles;uid=XXXXXXXX;pwd=xxxxx") rather than concatenating it from the contents of the text boxes.  I have Googled this and found other people with variations of the problem but no clear solution.  Can anyone tell me how to address this error or offer another solution that will let me "log in" to the AS400 from my web page?

     

    Thanks,

    Neal

    Tuesday, October 2, 2007 7:15 PM

All replies

  • You will have to show exact code showing how you generate the connection string...

    Code Block

    string format = "Dsn=njc_crfiles;uid={0};pwd={1}";
    string connectionString = string.format(format,  textBoxUserName.Text, textBoxPassword.Text);

    Wednesday, October 3, 2007 8:31 AM
  • Tim

    Among other things I have tried this:

     

    <%

    Dim strUID As String

    Dim strPWD As String

    strUID = TextBox1.Text

    strPWD = TextBox2.Text

    %>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Dsn=njc_crfiles;uid="&strUID&";pwd="&strPWD

     

    Your code looks interesting, but I am not sure how I would apply it to my situation. Could you walk me through it?

     

    Thanks,

    Neal

     

    Wednesday, October 3, 2007 5:54 PM
  • Imho, your code is an asp.net problem which is better answered at http://forums.asp.net
    Thursday, October 4, 2007 5:30 AM
  • Try building connection string using string builder, that may help you. If generated connection string is same as it is in web.config, it should work. Once you generate connection string, send both (generated and working one) on this post.

     

    Thursday, October 4, 2007 8:46 AM
  • Thanks for the suggestion, ILWD.

    I am afraid I am too much of a novice to put all the pieces together.  I have tried building the string using OdbcConnectionStringBuilder, which apparently will do just exactly what I want.  Unfortunately I don't even know who to display the string after it is built much less use it to connect my control to the database. Hopefully I will find someone who can look over my shoulder and give me step by step instructions. 

    Neal

     

    Thursday, October 4, 2007 6:58 PM