ASP.NET To You Blog's
Wednesday, September 24, 2008
ASP.NET Membership on Visual Studio 2005 by Microsoft SQL Server 2000 Configurations Step by step
Microsoft SQL Server 2000 Configurations Step by step
**************************************************************************
1. Create Database "test"
2. Run Command Prompt
3. Go to "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727"
4. Run "aspnet_regsql.exe"
5. Click "Next"
6. Select "Configure SQL Server for application services" and click "Next"
7. Enter name for Server in textbox
8. Select SQL Server authentication fill User name and Password
9. Select Database "test"
10. Click "Next"
11. Click "Next"
12. Click "Finish"
**************************************************************************
13. In Visual Studio 2005 Project add Configuration setting by code
-------------------------------------------------------------------------------------------------
<connectionstrings>
<remove name="LocalSqlServer">
<add name="LocalSqlServer" connectionString="data
source=.;Database=test;Uid=username;Pwd=password;" />
</connectionstrings>
-------------------------------------------------------------------------------------------------
***Remark : username = Your username for connect database
password = Your password for connect database
-------------------------------------------------------------------------------------------------
14. Create User, Role and other configuration by ASP.NET Configuration on menu Website>ASP.NET Configuration
**************************************************************************
Have a nice day.
Samrid
Sunday, September 21, 2008
Connect to Sql Database Files Class
Imports System.Data
Public Class SQLCONN
Dim PV As String = "data source=.\SQLEXPRESS;"
Dim m_Database As String = "DataDirectorydatabase.mdf;"
Public Strcon As String
Dim m_Identity As Integer
Public ReadOnly Property Identity() As Integer
Get
Return m_Identity
End Get
End Property
Public Sub New()
Strcon = PV & "Integrated Security=SSPI;AttachDBFilename=" & m_Database & "User Instance=true"
End Sub
Public Function GetDataset(ByVal Strsql As String, _
Optional ByVal DatasetName As String = "Dataset1", _
Optional ByVal TableName As String = "Table") As DataSet
Dim DA As New SqlDataAdapter(Strsql, Strcon)
Dim DS As New DataSet(DatasetName)
Try
DA.Fill(DS, TableName)
Catch x1 As Exception
Err.Raise(60002, , x1.Message)
End Try
Return DS
End Function
Public Function GetDataTable(ByVal Strsql As String, _
Optional ByVal TableName As String = "Table") As DataTable
Dim DA As New SqlDataAdapter(Strsql, Strcon)
Dim DT As New DataTable(TableName)
Try
DA.Fill(DT)
Catch x1 As Exception
Err.Raise(60002, , x1.Message)
End Try
Return DT
End Function
Public Function CreateCommand(ByVal Strsql As String) As SqlCommand
Dim cmd As New SqlCommand(Strsql)
Return cmd
End Function
Public Function Execute(ByVal Strsql As String, Optional ByVal IdentityCheck As Boolean = False) As Integer
Dim cmd As New SqlCommand(Strsql)
Dim X As Integer = Me.Execute(cmd, IdentityCheck)
Return X
End Function
Public Function Execute(ByRef Cmd As SqlCommand, Optional ByVal IdentityCheck As Boolean = False) As Integer
Dim Cn As New SqlConnection(Strcon)
Cmd.Connection = Cn
Dim X As Integer
Try
Cn.Open()
X = Cmd.ExecuteNonQuery()
If IdentityCheck = True Then
Dim cmd3 As New SqlCommand("select @@identity", Cn)
m_Identity = cmd3.ExecuteScalar
End If
Catch
X = -1
Finally
Cn.Close()
End Try
Return X
End Function
Public Sub CreateParam(ByRef Cmd As SqlCommand, ByVal StrType As String)
'T:Text, M:Memo, Y:Currency, D:Datetime, I:Integer, S:Single, B:Boolean, P: Picture
Dim i As Integer
Dim j As String
For i = 1 To Len(StrType)
j = UCase(Mid(StrType, i, 1))
Dim P1 As New SqlParameter
P1.ParameterName = "@P" & i
Select Case j
Case "T"
P1.SqlDbType = SqlDbType.VarChar
Case "M"
P1.SqlDbType = SqlDbType.Text
Case "Y"
P1.SqlDbType = SqlDbType.Money
Case "D"
P1.SqlDbType = SqlDbType.DateTime
Case "I"
P1.SqlDbType = SqlDbType.Int
Case "S"
P1.SqlDbType = SqlDbType.Decimal
Case "B"
P1.SqlDbType = SqlDbType.Bit
Case "P"
P1.SqlDbType = SqlDbType.Image
End Select
Cmd.Parameters.Add(P1)
Next
End Sub
End Class
Connect to MS Access Files Class
Imports System.Data
Imports System.Data.OleDb
Public Class ClassAccess
Public Strcon As String
Dim PV As String = "Provider=Microsoft.Jet.OLEDB.4.0;"
Dim m_DBPath As String = "C:\Inetpub\wwwroot\CarManagement\App_Data\DB.mdb"
Dim m_Password As String = "passwordmdb"
Dim m_Identity As Integer
Public ReadOnly Property Identity() As Integer
Get
Return m_Identity
End Get
End Property
Public Sub New()
If Dir(m_DBPath) = "" Then
Err.Raise(60001, , "Database File : " & m_DBPath & " Database not found")
Exit Sub
End If
Strcon = PV & "data source=" & m_DBPath & ";Jet OLEDB:Database Password=" & m_Password
End Sub
Public Function GetDataset(ByVal Strsql As String, _
Optional ByVal DatasetName As String = "Dataset1", _
Optional ByVal TableName As String = "Table1") As DataSet
Dim DA As New OleDbDataAdapter(Strsql, Strcon)
Dim DS As New DataSet(DatasetName)
Try
DA.Fill(DS, TableName)
Catch x1 As Exception
Err.Raise(60002, , x1.Message)
End Try
Return DS
End Function
Public Function GetDataTable(ByVal Strsql As String, _
Optional ByVal TableName As String = "Table1") As DataTable
Dim DA As New OleDbDataAdapter(Strsql, Strcon)
Dim DT As New DataTable(TableName)
Try
DA.Fill(DT)
Catch x1 As Exception
Err.Raise(60002, , x1.Message)
End Try
Return DT
End Function
Public Function CreateCommand(ByVal Strsql As String) As OleDbCommand
Dim cmd As New OleDbCommand(Strsql)
Return cmd
End Function
Public Function Execute(ByVal Strsql As String, Optional ByVal IdentityCheck As Boolean = False) As Integer
Dim cmd As New OleDbCommand(Strsql)
Dim X As Integer = Me.Execute(cmd, IdentityCheck)
Return X
Return Strsql
End Function
Public Function Execute(ByRef Cmd As OleDbCommand, Optional ByVal IdentityCheck As Boolean = False) As Integer
Dim Cn As New OleDbConnection(Strcon)
Cmd.Connection = Cn
Dim X As Integer
Try
Cn.Open()
m_Identity = 0
X = Cmd.ExecuteNonQuery()
If IdentityCheck = True Then
Dim cmd3 As New OleDbCommand("select @@identity", Cn)
m_Identity = cmd3.ExecuteScalar
End If
Catch
X = -1
Finally
Cn.Close()
End Try
Return X
End Function
Public Sub CreateParam(ByRef Cmd As OleDbCommand, ByVal StrType As String)
'T:Text, M:Memo, Y:Currency, D:Datetime, I:Integer, S:Single, B:Boolean
Dim i As Integer
Dim j As String
For i = 1 To Len(StrType)
j = UCase(Mid(StrType, i, 1))
Dim P1 As New OleDbParameter()
P1.ParameterName = "@P" & i
Select Case j
Case "T"
P1.OleDbType = OleDbType.VarChar
Case "M"
P1.OleDbType = OleDbType.LongVarChar
Case "Y"
P1.OleDbType = OleDbType.Currency
Case "D"
P1.OleDbType = OleDbType.Date
Case "I"
P1.OleDbType = OleDbType.Integer
Case "S"
P1.OleDbType = OleDbType.Decimal
Case "B"
P1.OleDbType = OleDbType.Boolean
End Select
Cmd.Parameters.Add(P1)
Next
End Sub
End Class
วิธีการแก้ปัญหาเมื่อ Login ไม่ได้
1. กำหนดสิทธิโฟลเดอร์ App_Data ให้สามารถเขียนได้
2. ปิด VS2005+IE+Service(IIS,Sql Express,www) ลบไฟล์ใน F:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
3. ลองทดสอบดูอีกครั้ง หากยังไม่ได้ ลองหาวิธีอื่น
Saturday, September 20, 2008
Delete recent files and Project from FILE MENU in Visual Studio 2005
You can try to remove the project from the Recent Projects list by following steps below:
1. Click Start, click Run, type Regedit, and then click OK.
2. Locate and then click the following key in the registry:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\ProjectMRUListNote
3. On the Edit menu, click Delete, and then click Yes to confirm.
4. Close Registry Editor.
I hope this helps.
ASP.NET 2.0 Guide by RidDick for VS2005 and .Net Framework SDK 2.0
ถึงวันนี้แล้วก็คงไม่มีใครปฏิเสธได้ว่าเทคโนโลยีก้าวไปอย่างรวดเร็วจนอยู่แทบทุกที่ที่เราอยู่ คงจะมีน้อยคนมากที่ไม่ได้ยุ่งเกี่ยวกับเทคโนโลยีเลย คนเราก็ช่างมีความมหัศจรรย์เหลือหลาย อะไรที่ไม่เคยมีคนคิดคนทำก็ช่างสรรค์หามาทำจนได้ เช่นกันกับตัวเราเองนี่แหละน๊า ที่อยู่ดี ๆ ก็ต้องมาศึกษาเทคโนโลยี .Net กับเขาเสียที
พอเริ่มปุ๊บก็เจอแล้วนะเรา ไม่ใช่ว่าเจอทางสว่างนะ แต่เจอตอที่เขาเรียกว่าปัญหาต่างหาก นี่ลแหละคือที่มาของการทำหัวข้อนี้ เพื่อว่าวันต่อไปจะได้นำกลับมาใช้อีก ถ้าจะมีใครสักคนจะเข้ามาดูและนำไปใช้ก็ไม่ว่ากัน แต่ต้องขอบอกไว้ก่อนว่าข้อมูลเหล่านี้ได้มาจากส่วนตัวเท่านั้น อาจจะถูกหรือผิดก็อย่าว่ากันนะ เอาเป็นว่าเริ่มเลยละกัน……………………………………………………………………………………………………………….
ขั้นตอนการติดตั้ง ASP.NET
1. Install IIS (XP,2000 or Higher)2. Install VS2005 (Don’t install .Net Framework because VS have them)3. Set IIS in TAB ASP.NET use ver. 2.0.xxxx –> VS2003 use ver. 1.0.xxxx –> VS2005 use ver. 2.0.xxxx4. Start VS2005 –> Select Web Developer –> Create new Project Website –> Select ASP.Net Website –> Location Select HTTP = http://localhost/Project name –> Language Select Visual Basic –> Click Ok to start develope –> Right click http://localhost/Project name to Create New Page and type name for your page –> Coding your application.
……………………………………………………………………………………………………………….
Exception for
แก้โดย เลือกเวอร์ชั่นของ .Net Framwork ให้ถูกต้อง –> VS2003 use ver. 1.0.xxxx –> VS2005 use ver. 2.0.xxxx
……………………………………………………………………………………………………………….
Exception = Failed to access IIS metabase.
แก้โดย
RUN –> cmd
–> cd C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
Execute Command –> aspnet_regiis -i
–> C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>aspnet_regiis -iStart installing ASP.NET (2.0.50727).……………………Finished installing ASP.NET (2.0.50727).
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>
……………………………………………………………………………………………………………….
Exception = Mutex could not be created.
แก้โดย
ลบไฟล์ที่เกี่ยวกับโปรเจกที่อยู่ใน C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files ออกให้หมดRestart IIS+VS2005+IE
……………………………………………………………………………………………………………….
วันนี้ต้องพอแค่นี้ก่อนแล้วเรา ง่วงแล้ว ไว้ต่อคราวหน้า
แซมริด
ASP.NET Development Books
ASP.NET Development Books
On this page you will find a book for all ASP.NET developers, from the novice to the professional. If you are new to ASP.NET, you can learn the basics of how to create dynamic web applications with ASP.NET 2.0 and Visual Web Developer 2005 Express Edition, using either Visual Basic or C#. If you have a bit of development experience, you will learn how to employ some of the great new features introduced in ASP.NET 2.0.