Need help with Sql Server connection string

HI,
I am copying some code from another uses software to my project and i am quite new in vb.net

from the user code, the connection string is :

 BCon = New sqlConnection("data source=micron;uid=sa;pwd=admin;initial catalog=gsmlanka")
 cartCon = New sqlConnection("data source=micron;uid=sa;pwd=admin;initial catalog=gsmlanka")
I can see, he used sql server username and password for his development
but in my pc , i am using sqlserver but windows authentication

I am trying with bellow code but its not working :


BCon = New sqlConnection("Data Source=GRAPHICS\sqlexpress;initial catalog=gsmlanka;Integrated Security=True")
 cartCon = New sqlConnection("Data Source=GRAPHICS\sqlexpress;initial catalog=gsmlanka;Integrated Security=True")

Error is below :

Cannot open database "gsmlanka" requested by the login. The login failed.
Login failed for user 'GRAPHICS\ASPNET'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Cannot open database "gsmlanka" requested by the login. The login failed.
Login failed for user 'GRAPHICS\ASPNET'.


Do i need to give some permission ?


but its not working , can any one tell me where i am doing wrong?
LVL 29
fosiul01Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
yes, you have to create the windows login in the sql server logins and grant the permissions to the database you want to connect to.
0
fosiul01Author Commented:
Hi
Sql server login is already windows login.
But how i will grant permission ??
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>Sql server login is already windows login.
you mean, sql server is configured to allow windows authentication?

that alone is not sufficient, you have to create a login in the sql server security that maps the windows login, and from there grant the permissions. see the below tip to show the screenshots (screenshot 2 is what you need to do):
http://www.acucorp.com/support/public/tech_tips/tips/tips_36.php

once such a login is created, you can (and have to) grant the permissions to the databases as to a normal sql login.
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

fosiul01Author Commented:
Hi, i am using Sql server  2005
I attached 2 pictures,
one is sqlserver management studio  express
other is: i connect other database frm vb.net (web sites), and its works , i didnot have to give any permission for anything.


Sqlserver2005.GIF
vb.net.GIF
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
that is how you try to connect.

the problem is not there, but in the logins defined.
you have to connect with a login that has the permission to connect, and create the logins as needed...

only then you can connect with a dedicated windows account.

note: by default, the local (on the sql box) windows administrators can connect using windows authentication...
0
fosiul01Author Commented:
omm, in that case
will you able to tell me, step by step, how to solve this issue please, as i said, i dont have enough knowledge about th is issue, i am learning
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
step 0: start sql management studio using a login that has permissions to create logins
 
then:
http://technet.microsoft.com/en-us/library/aa337562.aspx
<...>
   1. In SQL Server Management Studio, open Object Explorer and expand the folder of the server instance in which to create the new login.
   2. Right-click the Security folder, point to New, and then click Login.
   3. On the General page, enter the name of a Windows user in the Login name box.
   4. Select Windows Authentication.
   5. Click OK.
0
fosiul01Author Commented:
Hi
thanks
now i am getting following error :

Server Error in '/' Application.
--------------------------------------------------------------------------------

SELECT permission denied on object 'Manufacturer', database 'gsmlanka', schema 'dbo'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: SELECT permission denied on object 'Manufacturer', database 'gsmlanka', schema 'dbo'.

Source Error:


Line 5:  BCmd = New sqlCommand("select * from manufacturer order by man_id asc",Bcon )
Line 6:  Bcon.Open()
Line 7:  phnList.DataSource = BCmd.ExecuteReader()
Line 8:  phnList.DataBind()
Line 9:  BCon.Close()
 

Source File: c:\inetpub\wwwroot\shop\man_menu.aspx    Line: 7
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
that is step 2:
grant the select permissions for the user based on that login in your database for that table... ie for the other tables.
you might also grant the db_datareader role to that login, in case you want to have this user (login) read on all the tables in that database...
0
fosiul01Author Commented:
ok check 2 p ictures i have attached, tell where i am doing wrong,
i gave all permission as you said
still same error



sqlsstudio.GIF
sqlstudio1.GIF
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
you checked the db_denydatareader (and db_denydatawriter) roles, which override any other permissions to read (write) data.
uncheck those (at least), ie you should only have the db_datareader (and db_datawriter) checked for a normal login, all the others should not be checked..
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fosiul01Author Commented:
Done!!!
Thanks to help me to find out this soliution.


0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.