Blogtrottr
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中 
請教ASP.NET(VB)連接SQL的問題
Nov 27th 2014, 13:35

我要用ASP.NET(VB)寫個網頁可讓使用者登入及註冊的程式
但不知哪裡錯?
已註冊頁面為例,點下註冊button後之事件:
Dim Conn As SqlConnection = New SqlConnection("server=.\SQLEXPRESS;uid=test;pwd=800106;database=master")
Conn.Open()
Dim sqlstr As String = "Insert Into user_profile Values('&txtusername.Text&','&txtpassword.Text&','&txtnickname.Text&','&txtrealname.Text&','&txtemail.Text&')"
Dim cmd As New SqlCommand(sqlstr, Conn)
cmd.ExecuteNonQuery()

cmd.Cancel()
Conn.Close()
Conn.Dispose()
以上...
覺得是錯在連線字串?
連線字串裡到底要怎麼寫才對呢?以下三種寫法都還是錯...
1. Dim Conn As SqlConnection = New SqlConnection("Data Source=(localdb)\v11.0;AttachDbFilename=DataDirectory|db.mdf;Integrated Security=True")

2. Dim Conn As New SqlConnection("Data Source=(localdb)\v11.0;Integrated Security=SSPI;Initial Catalog=master")

3. Dim Conn As SqlConnection = New SqlConnection("Server=.\SQLEXPRESS;Database=master;User Id=test;Password=800106")

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers.

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions
arrow
arrow
    全站熱搜

    kkoki0httzobg 發表在 痞客邦 留言(0) 人氣()