![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Apr 2008
Location: flagstaff az
Posts: 18
Rep Power: 0
![]() |
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();
}
}
} |
|
|
|
|
|
#2 |
|
Newbie
Join Date: Apr 2008
Location: flagstaff az
Posts: 18
Rep Power: 0
![]() |
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. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
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 |