database connection

  • Thread starter Thread starter djozy
  • Start date Start date
D

djozy

Please,I have made database in Sql server. How to connect
with it? It is,lets say,in C:\temp and its name is
database1. What do I need to put here:
SqlConnection conn=new SqlConnection("Data
Source=localhost;User Id=sa;Password=pwd;Initial
Catalog=database1;");?
When I put this it doesn't work. When I put whatever it
doesn't work and it doesn't show error message.
Tahnk you
 
Is your database attached to SQL Server? If not you will have to attach teh
file first. There may be a connection string option that connects the file,
but I don't know what it is offhand.
Now, the connection string isn't tested until you call conn.Open() I don't
think, try calling the open method on your connection object and seeing what
exception is thrown, then post back.
 
I am trying to conect my application with SQL Server
database using connection string. But I don't know how to
specify location of my database and table which I want to
use. I have done what you had said to me ant this
exception has been thrown: "Login failed for user 'JOSIP-
SKY2IGFE7\ASPNET'". 'JOSIP-SKY2IGFE7' is name of my local
server.Thank you for reply
 
djozy said:
I am trying to conect my application with SQL Server
database using connection string. But I don't know how to
specify location of my database and table which I want to
use. I have done what you had said to me ant this
exception has been thrown: "Login failed for user 'JOSIP-
SKY2IGFE7\ASPNET'". 'JOSIP-SKY2IGFE7' is name of my local
server.Thank you for reply

Ok, that means your ASPNET user doesn't have access to the SQL server. You
will either have to have to set that in SQL Server or you need to login with
an sql login. The default catalog is the database, and the table is
specified in the individual sql statements you issue, not in the connection
string.
 
Back
Top