Connection string

Last post 11-06-2009 8:47 AM by medic9204. 6 replies.

Sort Posts:

  • Connection string

    11-05-2009, 3:53 PM
    • Member
      point Member
    • medic9204
    • Member since 11-05-2009, 3:48 PM
    • Lemoyne, PA
    • Posts 4

    I am trying to get my form to connect to a mySQL on a windows-based GoDaddy server and I keep getting errors. I talked to them, and they said their test script works fine so it's a script error on my part but they won't tell me what my error is.


    So, here is my code. Obviously I'm not posting my credentials and assume my variables are all declared elsewhere.


    'database connection
    adoCon = Server.CreateObject("ADODB.Connection")
    strConnection = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=solid.db.xxxxx.hostedresource.com; PORT=3306; DATABASE=solid;   USER=xxx; PASSWORD='xxx'; OPTION=0;"
    adoCon.Open strConnection
    adoCon.execute(strSQL)

    'close database connections
    adoCon.Close
    adoCon = Nothing

    Please help!

  • Re: Connection string

    11-05-2009, 4:11 PM
    • Member
      118 point Member
    • LuizFicer
    • Member since 03-13-2009, 4:45 AM
    • Lima-Peru
    • Posts 54

    use OLEDB CONNECTION

  • Re: Connection string

    11-05-2009, 4:20 PM
    • Member
      point Member
    • medic9204
    • Member since 11-05-2009, 3:48 PM
    • Lemoyne, PA
    • Posts 4

    Okay, I tried that and now I get

    Security Exception

    Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

    Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

    Source Error:

    Line 122:'database connection
    Line 123:
    Line 124:adoCon = Server.CreateObject("OLEDB.Connection")
    Line 125:strConnection = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=solid.db.xxx.hostedresource.com; PORT=3306; DATABASE=xxx; USER=solid; PASSWORD='xxx'; OPTION=0;"
    Line 126:adoCon.Open (strConnection)

    Source File: d:\hosting\willseye\donations\give\submit.aspx    Line: 124

    Stack Trace:

    [SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
    System.Web.HttpServerUtility.CreateObject(String progID) +45
    ASP.donations_give_submit_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in d:\hosting\willseye\donations\give\submit.aspx:124
    System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256
    System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
    System.Web.UI.Page.Render(HtmlTextWriter writer) +29
    System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6785
    System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +242
    System.Web.UI.Page.ProcessRequest() +80
    System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
    System.Web.UI.Page.ProcessRequest(HttpContext context) +49
    ASP.donations_give_submit_aspx.ProcessRequest(HttpContext context) +37
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75


    Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.3053


    My code is now:

    'database connection

    adoCon = Server.CreateObject("OLEDB.Connection")
    strConnection = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=solid.db.xxx.hostedresource.com; PORT=3306; DATABASE=solid; USER=xxx; PASSWORD='xxx'; OPTION=0;"
    adoCon.Open (strConnection)
    adoCon.execute(strSQL)

    'close database connections
    adoCon.Close
    adoCon = Nothing

  • Re: Connection string

    11-05-2009, 4:36 PM
    • Member
      118 point Member
    • LuizFicer
    • Member since 03-13-2009, 4:45 AM
    • Lima-Peru
    • Posts 54


    Provider=MySQLProv;Data Source=mydb;User Id=myUsername;Password=myPassword;

    and your class conexion use

    oledbconnection = new oledbconecction and get your string connection of your web config or u can set mannually in variable string


     

  • Re: Connection string

    11-05-2009, 4:38 PM
    • Member
      118 point Member
    • LuizFicer
    • Member since 03-13-2009, 4:45 AM
    • Lima-Peru
    • Posts 54


    Provider=MySQLProv;Data Source=mydb;User Id=myUsername;Password=myPassword;

    and in your class conexion use

    oledbconection = new oledbconnection (
    Provider=MySQLProv;Data Source=mydb;User Id=myUsername;Password=myPassword;

  • Re: Connection string

    11-06-2009, 8:34 AM
    • Member
      point Member
    • medic9204
    • Member since 11-05-2009, 3:48 PM
    • Lemoyne, PA
    • Posts 4

    I am not sure what you mean here. This?


    adoCon = Server.CreateObject("OLEDB.Connection")
    strConnection = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=solid.db.xxx.hostedresource.com; PORT=3306; DATABASE=xxx; USER=xxx; PASSWORD='xxx'; OPTION=0;"
    adoCon = new adoCom (strConnection)
    adoCon.execute(strSQL)

  • Re: Connection string

    11-06-2009, 8:47 AM
    • Member
      point Member
    • medic9204
    • Member since 11-05-2009, 3:48 PM
    • Lemoyne, PA
    • Posts 4

    Now I get:


    Compilation Error

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: BC30002: Type 'oleCon' is not defined.

    Source Error:


    Line 124:oleCon = Server.CreateObject("OLEDB.Connection")
    Line 125:strConnection = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=solid.db.xxx.hostedresource.com; PORT=3306; DATABASE=xxx; USER=solid; PASSWORD='xxx'; OPTION=0;"
    Line 126:oleCon = new oleCon (strConnection)
    Line 127:oleCon.execute(strSQL)
    Line 128:

    Source File: d:\hosting\willseye\donations\give\submit.aspx    Line: 126


Page 1 of 1 (7 items)