Fetstil Fetstil Kursiv Understrykning linje färgläggning tabellverk Punktlista Nummerlista Vänster Centrerat högerställt Utfyllt Länk Bild htmlmode
  • Forum & Blog
    • Forum - översikt
      • .Net
        • asp.net generellt
        • c#
        • vb.net
        • f#
        • silverlight
        • microsoft surface
        • visual studio .net
      • databaser
        • sql-server
        • databaser
        • access
        • mysql
      • mjukvara klient
        • datorer och komponenter
        • nätverk, lan/wan
        • operativsystem
        • programvaror
        • säkerhet, inställningar
        • windows server
        • allmänt
        • crystal reports
        • exchange/outlook
        • microsoft office
      • mjukvara server
        • active directory
        • biztalk
        • exchange
        • linux
        • sharepoint
        • webbservers
        • sql server
      • appar (win/mobil)
      • programspråk
        • c++
        • delphi
        • java
        • quick basic
        • visual basic
      • scripting
        • asp 3.0
        • flash actionscript
        • html css
        • javascript
        • php
        • regular expresssion
        • xml
      • spel och grafik
        • DirectX
        • Spel och grafik
      • ledning
        • Arkitektur
        • Systemutveckling
        • krav och test
        • projektledning
        • ledningsfrågor
      • vb-sektioner
        • activeX
        • windows api
        • elektronik
        • internet
        • komponenter
        • nätverk
        • operativsystem
      • övriga forum
        • arbete karriär
        • erbjuda uppdrag och tjänster
        • juridiska frågor
        • köp och sälj
        • matematik och fysik
        • intern information
        • skrivklåda
        • webb-operatörer
    • Posta inlägg i forumet
    • Chatta med andra
  • Konto
    • Medlemssida
    • Byta lösenord
    • Bli bonsumedlem
    • iMail
  • Material
    • Tips & tricks
    • Artiklar
    • Programarkiv
  • JOBB
  • Student
    • Studentlicenser
  • KONTAKT
    • Om pellesoft
    • Grundare
    • Kontakta oss
    • Annonsering
    • Partners
    • Felanmälan
  • Logga in

Hem / Forum översikt / inlägg

Posta nytt inlägg


Jag har problem med att koppla mot SQL Db.. Jag är N00b så, bear with

Postades av 2004-03-11 16:57:57 - Kim Hult, i forum asp.net generellt, Tråden har 4 Kommentarer och lästs av 514 personer

Så här ser min kod ut:
----------------------------------------------------------------------------------

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Skapa connectionobjektet med connectionstring i parentesen
Dim cn As New SqlConnection("Server=localhost;Database=DiaryDb;Trusted_Connection=True;")

' Skapa SQL-satsen
Dim strSql As String = "SELECT * FROM Fnamn"

' Dimensionera en dataadapter
Dim adpAdapter As New SqlDataAdapter(strSql, cn)

' Fyll datasetet
adpAdapter.Fill(dsDataset)

TextBox1.Text = dsDataset.Tables(0).Rows(0).Item(0)
TextBox2.Text = dsDataset.Tables(0).Rows(0).Item(1)
End Sub

Felmeddelandet jag får ser ut så här:
----------------------------------------------------------------------------------------------
Login failed for user 'MINBURK\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: Login failed for user 'MINBURK\ASPNET'.

Source Error:


Line 45:
Line 46: ' Fyll datasetet
Line 47: adpAdapter.Fill(dsDataset)
Line 48:
Line 49: TextBox1.Text = dsDataset.Tables(0).Rows(0).Item(0)
---------------------------------------------------------------------------------------------

Varför vill det sig inte? Jag antar att det har med vart min Db ligger? hur ser jag det? och jag skall ju inte ha ett lösen på den vad jjag et, utan den skall ju vara "öppen"..
Jag kommer inte vidare, kan nån hjälpa mig?
Tack skall ni ha..
Kim.


Svara

Sv: Jag har problem med att koppla mot SQL Db.. Jag är N00b så, bear w

Postades av 2004-03-12 09:53:05 - Mikael Ljunghorn

Öppna "Enterprise Manager" (för SQL server).
Expander trädet till SQL Servern.
Högerklicka och välj "Properties".
Klicka på fliken "Security".
Kolla vad som är angivet under "Authentication".
Det ska vara "SQl Server and Windows" för att det ska fungera.

Du kan också prova att ändra din anslutningssträng till
<code>
Dim cn As New SqlConnection("Server=localhost;Database=DiaryDb;UID=sa;PWD=")
</code>
för att se om det fungerar.


Svara

Sv: Jag har problem med att koppla mot SQL Db.. Jag är N00b så, bear

Postades av 2004-03-12 10:10:44 - Mikael Ljunghorn

Prova även följande:

<code>
Dim cn As New SqlConnection("Data Source=localhost;Initial Catalog=DiaryDB;Integrated Security=SSPI;")

' Skapa SQL-satsen
Dim strSql As String = "SELECT * FROM Fnamn"

' Dimensionera en dataadapter
Dim adpAdapter As New SqlDataAdapter(strSql, cn)

' Fyll datasetet
Dim dsdataset As DataSet = New DataSet
adpAdapter.Fill(dsdataset)

MessageBox.Show("Done")
</code>


Svara

Sv: Jag har problem med att koppla mot SQL Db.. Jag är N00b så, bear w

Postades av 2004-03-12 13:01:46 - paul horsley

THere are a few things to think about before deciding on which type of solution to your problem you want to use,

Security for one,
if your using sql 2000 then you should not really be using SQL Server and Windows security but only use windows NT security, you can see in 2k you only have to choices.

If the sql server your connecting to is on the same machine as your application then the MachineName/aspnet can work but if your app is trying to connect to the sql server that's on another machine then the macinhe naem/aspnet user can never be set up properly.

Also when useing a connection string with user credentials ( userAcc & Password ) your should try to always use something like the following example where you tell the connection ado object not to show in ascii the user credentials over the lan
ex:
Constring = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=UsrName;password=Password;Initial Catalog=DBname;Data Source=SQLservername"

For more info on connection string try here www.connectionstrings.com , they go everything you might need.


I had some of the same problems your experiencing, the way I fixed it was two stages,

1) Set up a LAN user or local user on the sqlserver ( LAN User Preferred )

2) In the web.config add this parameter

<identity impersonate="true" UserName="DomainOrMachineName\SomeUser" password="SomePassword"></identity>

(you should read .Net dox about imersonation this usage )

Then on the sql server added the user to the loacl OS user manager,

After this I was ok,

Also I went into the sql server enterprise manager and explicitly set the new user to have access to the required views / tables and stored Procedures.


I know this is a lot to think about but if you start off by doing things with security in mind it might save time in the future


Also MS have a .net data component which I use most of the time, you can get it here

http://www.microsoft.com/downloads/details.aspx?FamilyID=f63d1f0a-9877-4a7b-88ec-0426b48df275&DisplayLang=en


It saves a lot of time coding.
I did find that if used from ASP.net then you should pass the connection object to the sqlhelper class, other wise you can end up with closed connections when you do thing you should have.


Good luck Paul

All information given is to be view and used at your own risk.
Paul Horsley takes no responsibility for content given or recieved.



Svara

Sv: Jag har problem med att koppla mot SQL Db.. Jag är N00b så, bear

Postades av 2004-03-12 13:11:25 - Kim Hult

Tack så mycket, jag fick ordning på det tillslut på just det sättet!
Tack.


Svara

Nyligen

  • 09:09 Vill du köpa medicinska tester?
  • 12:47 Vem beviljar assistansen – kommune
  • 14:17 Någon med erfarenhet av hemstädnin
  • 14:14 Bör man använda sig av en båtförme
  • 14:12 Finns det någon intressant hundblo
  • 14:25 Tips på verktyg för att skapa QR-k
  • 14:23 Tips på verktyg för att skapa QR-k
  • 20:52 Fungerer innskuddsbonuser egentlig

Sidor

  • Hem
  • Bli bonusmedlem
  • Läs artiklar
  • Chatta med andra
  • Sök och erbjud jobb
  • Kontakta oss
  • Studentlicenser
  • Skriv en artikel

Statistik

Antal besökare:
Antal medlemmar:
Antal inlägg:
Online:
På chatten:
4 569 165
27 952
271 704
787
0

Kontakta oss

Frågor runt konsultation, rådgivning, uppdrag, rekrytering, annonsering och övriga ärenden. Ring: 0730-88 22 24 | pelle@pellesoft.se

© 1986-2013 PelleSoft AB. Last Build 4.1.7169.18070 (2019-08-18 10:02:21) 4.0.30319.42000
  • Om
  • Kontakta
  • Regler
  • Cookies