database connection

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • djozy

    #1

    database connection

    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=localhos t;User Id=sa;Password= pwd;Initial
    Catalog=databas e1;");?
    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
  • Daniel O'Connell

    #2
    Re: database connection

    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.
    "djozy" <anonymous@disc ussions.microso ft.com> wrote in message
    news:03f601c3b6 1a$a5641370$a40 1280a@phx.gbl.. .[color=blue]
    > 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=localhos t;User Id=sa;Password= pwd;Initial
    > Catalog=databas e1;");?
    > 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[/color]


    Comment

    • djozy

      #3
      Re: database connection

      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\ASPNE T'". 'JOSIP-SKY2IGFE7' is name of my local
      server.Thank you for reply[color=blue]
      >-----Original Message-----
      >Is your database attached to SQL Server? If not you will[/color]
      have to attach teh[color=blue]
      >file first. There may be a connection string option that[/color]
      connects the file,[color=blue]
      >but I don't know what it is offhand.
      >Now, the connection string isn't tested until you call[/color]
      conn.Open() I don't[color=blue]
      >think, try calling the open method on your connection[/color]
      object and seeing what[color=blue]
      >exception is thrown, then post back.
      >"djozy" <anonymous@disc ussions.microso ft.com> wrote in[/color]
      message[color=blue]
      >news:03f601c3b 61a$a5641370$a4 01280a@phx.gbl. ..[color=green]
      >> Please,I have made database in Sql server. How to[/color][/color]
      connect[color=blue][color=green]
      >> 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=localhos t;User Id=sa;Password= pwd;Initial
      >> Catalog=databas e1;");?
      >> 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[/color]
      >
      >
      >.
      >[/color]

      Comment

      • Daniel O'Connell

        #4
        Re: database connection


        "djozy" <anonymous@disc ussions.microso ft.com> wrote in message
        news:086601c3b6 89$e48d5bf0$a40 1280a@phx.gbl.. .[color=blue]
        > 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\ASPNE T'". 'JOSIP-SKY2IGFE7' is name of my local
        > server.Thank you for reply[/color]

        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.
        [color=blue][color=green]
        > >-----Original Message-----
        > >Is your database attached to SQL Server? If not you will[/color]
        > have to attach teh[color=green]
        > >file first. There may be a connection string option that[/color]
        > connects the file,[color=green]
        > >but I don't know what it is offhand.
        > >Now, the connection string isn't tested until you call[/color]
        > conn.Open() I don't[color=green]
        > >think, try calling the open method on your connection[/color]
        > object and seeing what[color=green]
        > >exception is thrown, then post back.
        > >"djozy" <anonymous@disc ussions.microso ft.com> wrote in[/color]
        > message[color=green]
        > >news:03f601c3b 61a$a5641370$a4 01280a@phx.gbl. ..[color=darkred]
        > >> Please,I have made database in Sql server. How to[/color][/color]
        > connect[color=green][color=darkred]
        > >> 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=localhos t;User Id=sa;Password= pwd;Initial
        > >> Catalog=databas e1;");?
        > >> 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[/color]
        > >
        > >
        > >.
        > >[/color][/color]


        Comment

        Working...