The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Error SQL Server does not exist or access denied how to handle ?

Discussion in 'Database Discussions' started by myloveshopteen, Nov 22, 2014.

  1. myloveshopteen

    myloveshopteen Registered

    Joined:
    Nov 22, 2014
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    This error while writing his OLEDB connection to sql , sql user and the window are not to be .
    Use SQLOLEDB , slqncli have not been .
    Please any help !

    Code:
    // Create a connection string:
                string connectionString = "Provider = sqloledb; server = (local)\\sqlexpress; database = qlsinhvien; uid = [Removed]; pwd = [Removed] ;integrated security = sspi";
     
                // Create OleDbConnection object to connect to the database: qlsinhvien:
                OleDbConnection myOleDbConnection = new OleDbConnection(connectionString);
     
                // Create OleDbCommand object and connect to the myOleDbConnection:
                OleDbCommand myOleDbCommand = myOleDbConnection.CreateCommand();
     
                // set the CommandType property of the OleDbCommand object to TableDirect:
                myOleDbCommand.CommandType = CommandType.TableDirect;            
     
                try
                {
                    myOleDbConnection.Open();
                    MessageBox.Show("Connection opened.");
                   
                    // Set the CommandText property of the OleDbCommand object to
                    // the name of the table to retrieve from:
                    myOleDbCommand.CommandText = "sinh_vien";
     
                    // Create OleDbDataReader object for the ExecuteReader() method:
                    OleDbDataReader myOleDbDataReader = myOleDbCommand.ExecuteReader();
     
                    // Only read the first 3 rows from the OleDbDataReader object:
                    StringBuilder sb = new StringBuilder();
                    for (int count = 1; count <= 3; count++)
                    {
                        myOleDbDataReader.Read();
     
                        sb.AppendLine("myOleDbDataReader[\"ma_sinh_vien\"] = " + myOleDbDataReader["ma_sinh_vien"]);
                        sb.AppendLine("myOleDbDataReader[\"ten_sinh_vien\"] = " + myOleDbDataReader["ten_sinh_vien"]);
                        sb.AppendLine("myOleDbDataReader[\"hoc_bong\"] = " + myOleDbDataReader["hoc_bong"]);
                       
                        sb.AppendLine();                    
                    }
     
                    myOleDbDataReader.Close();
                    MessageBox.Show("OleDbDataReader closed.");
     
                    MessageBox.Show(sb.ToString());
                }
                catch (OleDbException ex)
                {
                    MessageBox.Show("Connection not found: " + ex.Message, "Error");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Another error: " + ex.Message, "Error");
                }
                finally
                {
                    myOleDbConnection.Close();
                    MessageBox.Show("Connection closed.");
                }
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    654
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    Your access level is listed as "Website Owner". Have you reported this issue to your web hosting provider and verified it's supported? The output suggests the connection is not intended for MySQL.

    Thank you.
     
Loading...

Share This Page