Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 17th, 2008, 12:04 PM   #1
ghg5
Newbie
 
Join Date: Apr 2008
Location: flagstaff az
Posts: 18
Rep Power: 0 ghg5 is on a distinguished road
Help with sql connection

I have a simple data reader connecting to my database on the local machine (for a web form) but I cannot get the security permissions to check out on my sql connection. I have tried using a user name and password instead of the integrated security and typing in the server name instead of local but I still get the same permissions error. I also tried changing all the permissions allowed to the different users in the server studio. I am fairly new to ado.net and using sql servers so it could well be something obvious. I have a MySql database working with my c# web apps so it is driving me crazy that I cant get the Microsoft product to work with my current web app.
This is the error message I keep getting.........."Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."

Here is the code I have for my reader. I am simply trying to pass all the strings into an array for now. Thanks for any suggestions.
SqlConnection conn;

        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            //set up sql connection and querry command from UserName database
            conn = new SqlConnection("Data Source=(local);Initial Catalog=UserName;Integrated Security=SSPI;");
            SqlDataReader rdr = null;
            //create an array to compare passwords in database to typed in password
            string[] Pword = new string[0];
 
            try
            {
                // Open the connection
                conn.Open();

                SqlCommand cmd = new SqlCommand("select Password from Login", conn);
                int x = 0;
                // 2. Call Execute reader to get query results
                rdr = cmd.ExecuteReader();

                // print the CategoryName of each record
                while (rdr.Read())
                {
                    Pword[x]=rdr[0].ToString();
                     x++;
                }
            }
            finally
            {
                // close the reader
                if (rdr != null)
                {
                    rdr.Close();
                }
 
                // Close the connection
                if (conn != null)
                {
                     conn.Close();
                }
            }   
        }
ghg5 is offline   Reply With Quote
Old May 19th, 2008, 2:00 PM   #2
ghg5
Newbie
 
Join Date: Apr 2008
Location: flagstaff az
Posts: 18
Rep Power: 0 ghg5 is on a distinguished road
Re: Help with sql connection

I got it working....seems that I had my password for the server set wrong and so the security didn't match.
ghg5 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sql Database connection Apophis Visual Basic .NET 2 Apr 28th, 2008 4:03 PM
SQL Problem Shivan PHP 2 Feb 29th, 2008 9:43 PM
Need to figure out the best way to confirm a VNC connection... diablo75 Visual Basic .NET 8 Nov 4th, 2007 10:27 PM
Detach an in-use database via code (SQL Server 2000) sma_soft C# 1 Aug 14th, 2007 2:22 PM
SMTPlib - Connection reset by peer Sane Python 2 Jun 20th, 2006 5:40 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:50 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC