CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2007
    Posts
    405

    connect to sql server 2005 via text file( with .ini extension)

    file settings.ini

    [Connection_String]
    Driver={SQL Server}
    Server=113.160.248.114,1434
    Database=Northwind
    Uid=xyz
    Pwd=123
    Trusted_Connection=yes



    Dim MyConnect As New ADODB.Connection
    Dim MyRecSet As New ADODB.Recordset
    Dim strSQL As String
    Dim COMMFilePath As String
    COMMFilePath = GetINISetting("COMM", "FilePath", Application.Path & " ")
    MyConnect.Open _
    "Driver={SQL Server};" & _
    "Server = Trim(GetINISetting("Connection_String", "Server", Application.Path & " SETTINGS.INI"));" & _
    "Database = Trim(GetINISetting("Connection_String", "Database", Application.Path & " SETTINGS.INI"));" & _
    "Uid = Trim(GetINISetting("Connection_String", "Uid", Application.Path & " SETTINGS.INI"));" & _
    "Pwd = Trim(GetINISetting("Connection_String", "Pwd", Application.Path & " SETTINGS.INI"));" & _
    "Trusted_Connection = Trim(GetINISetting("Connection_String", "Trusted_Connection", Application.Path & " SETTINGS.INI"));"

    My code above fails, do not work or who have read the example text file. Ini shared with me. thanks

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: connect to sql server 2005 via text file( with .ini extension)

    Is your database even set up to allow remote connections?
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: connect to sql server 2005 via text file( with .ini extension)

    Try without the port #
    Code:
    Server=113.160.248.114
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  4. #4
    Join Date
    Sep 2007
    Posts
    405

    Re: connect to sql server 2005 via text file( with .ini extension)

    I'm looking for example to connect SQL Server instance via ini file or a separate file connectivity to SQL Server I own a configuration file for multiple computers

  5. #5
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: connect to sql server 2005 via text file( with .ini extension)

    Using an ini file makes no difference, provided that you have the correct values in the ini file then it would work just as if they were hard coded.
    That said you had another thread where the values were hard coded and it was not working and if you have not solved that issue then using an ini file is just adding to the possible areas where you may have a problem.

    You also did not answer the question as to if the server is setup to allow remote connections.

    I seem to remember you saying that you were able to connect on your local machine but when trying to connect to the db on a remote machine you could not connect. If that be the case then an ini file is not going to help. You need to make sure the server is set to allow remote connections and make sure you are using the correct connection info. You also need to make sure that port is not blocked by the firewall.

    Also you say it fails but not even a hint as to what actually happens, error message?
    Hard to provide help when you do not provide enough info.
    Always use [code][/code] tags when posting code.

  6. #6
    Join Date
    Sep 2007
    Posts
    405

    Re: connect to sql server 2005 via text file( with .ini extension)

    Hi DataMiser! Thank you to read my question. the connections are done. I want to delete the user's abc Northwin an error, you can see my attached image file.

    Name:  delete_user.jpg
Views: 1239
Size:  96.4 KB

  7. #7
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: connect to sql server 2005 via text file( with .ini extension)

    Well that question has nothing to do with VB at all, but the error message is telling you what the problem is. It says that the user owns a schema and can not be deleted which means you would need to remove the schema and any other objects owned by that user first.
    Always use [code][/code] tags when posting code.

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

Featured