Saturday, November 27, 2010

วิธีใช้งาน visual Basic 2005 กับ ฐานข้อมูล SQL Server 2005


วิธีใช้งาน visual Basic 2005 กับ ฐานข้อมูล SQL Server 2005
เมื่อกี่ไปเห็นที่ Google Guru มีคนถามถึงเรื่องนี้งั้นผมขอ แชร์ด้วยคนนะครับ

สร้าง connection ก่อนครับ

Module conndb

Public SLDBconnection As String = ReadINI.INIRead(Path.GetFullPath(".") & "\dbini.ini", "APPCONFIG", "SLDBconnection", "")


End Module
-----------------------------------------------------------------------------
ส่วนใน DBini file นั้นผมเขียนไว้ประมาณนี้ครับ


[APPCONFIG]
SLDBconnection = Data Source=nb-montree;database=Database;uid=sa;pwd=sa



usr=
pwd=

----------------------------------------------------------------

ต่อไป Class สำหรับอ่าน ini ครับ

Public Class ReadINI
#Region "API Calls"
' standard API declarations for INI access
' changing only "As Long" to "As Int32" (As Integer would work also)
Private Declare Unicode Function WritePrivateProfileString Lib "kernel32" _
Alias "WritePrivateProfileStringW" (ByVal lpApplicationName As String, _
ByVal lpKeyName As String, ByVal lpString As String, _
ByVal lpFileName As String) As Int32
Private Declare Unicode Function GetPrivateProfileString Lib "kernel32" _
Alias "GetPrivateProfileStringW" (ByVal lpApplicationName As String, _
ByVal lpKeyName As String, ByVal lpDefault As String, _
ByVal lpReturnedString As String, ByVal nSize As Int32, _
ByVal lpFileName As String) As Int32
#End Region

Public Shared Function INIRead(ByVal INIPath As String, _
ByVal SectionName As String, ByVal KeyName As String, _
ByVal DefaultValue As String) As String
' primary version of call gets single value given all parameters
Dim n As Int32
Dim sData As String
sData = Space$(1024) ' allocate some room
n = GetPrivateProfileString(SectionName, KeyName, DefaultValue, _
sData, sData.Length, INIPath)
If n > 0 Then ' return whatever it gave us
INIRead = sData.Substring(0, n)
Else
INIRead = ""
End If
End Function

End Class
---------------------------------------------------------------------
จากนั้นก็ลงมือสร้าง ฟอร์ม หน้าตาแบบนี้ แล้วก็ประยุคต์ source code ดูนะครับ






Public Class frmitem



Private Sub btnsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsearch.Click
Dim connection As New SqlConnection
Dim da As SqlDataAdapter
Dim ds As DataSet = New DataSet

With connection
If .State = ConnectionState.Open Then .Close()
.ConnectionString = SLDBconnection
.Open()
End With


Dim command As SqlCommand = New SqlCommand("STPxListItem", connection)
command.CommandText = "Exec STPxListItem '" & txtsitem.Text & "'"
command.Connection = connection 'Active Connection


da = New SqlDataAdapter(command)
da.Fill(ds, "litem")


If ds.Tables("litem").Rows.Count <> 0 Then

With grdview
.ReadOnly = True
.DataSource = ds.Tables("litem")
End With

Else

grdview.DataSource = Nothing
End If



End Sub
End Class

Friday, November 26, 2010

Percent Discount

วิธีคิด เปอร์เซ็นส่วนลดสินค้า

วิธี คำนวณ เปอร์เซ็นส่วนลดสินค้า เสื้อผ้า

วันนี้ผมมี วิธี คำนวณ ส่วนลดสินค้าว่าที่ร้านลดให้เรานั้นคิดเป็น กี่เปอร์เซ็นกันแน่
ตัวอย่างเช่น ร้านขาย เสื้อผ้าแฟชั่นสไตล์เกาหลี ร้านขาย แฟชั่นสไตล์เกาหลี ติดป้าย ราคาขาย เสื้อผ้าแฟชั่นสไตล์เกาหลี ไว้ 1300 ผมเข้าไปต่อราคาเหลือ 850 บาท และถ้าผมอยากรู้ว่า ร้านนั้นเขาลดราคาให้ผมกี่เปอร์เซ็นกันแน่นะ มาเริ่มกันเลยดีกว่า

ผมกำหนดให้ ราคาเก่า = X ,ราคาใหม่ = Y , Z = จำนวนเงินส่วนลด
z = x - y
z = 1300 - 850
z = 450 บาท

ฉะนั้นผมรู้แล้วว่าร้าน ขาย เสื้อ เสื้อแฟชั่นสไตเกาหลี ลดให้ผม 450 บาท แล้ว 450 บาทนั้นคิดเป็นกี่เปอร์เซ็นของ 1300 ล่ะครับที่นี้
PD = Percent Discount
PD = (z/x) x 100
แทนค่า

PD = (450/1300) x 100
PD = 34.61 %

ฉะนั้นเราก็รู้แล้วนะครับว่าเราได้ส่วนลดตั้ง 34.61 เปอร์เซ็นเลยที่เดียว
ผมคิดว่าสูตรง่ายพวกนี้เป็นสิ่งที่เราไม่ควรมองข้ามนะครับเลยเก็บมาฝากเพื่อน ๆ พี่ ๆ น้อง ๆ ครับ

Saturday, November 20, 2010

Link for Free web directory submit

Link for Free web directory submit, free web site submit,submit web page
Hi,Friend. You are looking for free Link Submit Web high Rank .
This link help you to finding the High Rank(PR) and Free Submittion web . you can click on the link
and then you find out the web for you submit, i think,You choose PR each the web should be that more than you web site or you choose PR > 2 and then when you stay on the submittion web you must to find out wording is Submit Link,Submit site ,something like that.
Okay Let go to Free web directory submit.

Friday, November 19, 2010

การ add on new domain name to hosting of godaddy.com

วิธีการ How to add on new domain name to hosting of godaddy.com

Hi ,Friend,I can help you to add secound new domain name to godaddy.com.
you can follow by below.

1. Login to www. godaddy.com
- Log in with user name and Password of your host
2. choose the host name for you need to add new domain name .
3.Click Launch Button


4. Look at the Menu Click on the

"Setting" and then " Domain Management"

5.Look at the right Top Screen clikc on "Add Domain"

6.fill in the your domain for example 9montree.com

7.Choose the Path or create new the folder for keep your website files.

8. Finish the Step for Add on domain name to hosting of www.godaddy.com


Thank you.


Monday, November 15, 2010

Solution for correct Limited or no Connectivity wireless on Laptop windows xp,vista

Solution for correct " Limited or no Connectivity wireless " on Notebook ,Laptop used windows xp,vista

Hi , friend , I have found the problem can't connect to the network and then i have check the Network Icon and then i took double click on that i have found the message is " Limited or no Connectivity wireless " .

Solution : Reinstall the Wireless and then please sure, you uninstall the old driver first and then
restart Machine and install Wireless Driver on Laptop againts.

Thank you.

ms sql server 2005 restore failed because the database is in use.

Ms sql server 2005,Express,2008 restore failed on ERP Syteline Database because the database is in use. Hi, Friend.If you looking for solution for restore database with out error same below

" system.data.sqlclient.sqlerror:exclusive access could not be obtained because the database is in use. "


from message above i sure , you have been restoring the database while that have the application is in use so i have script for find out the problem .

1. Log in to sql server -> create new query -> key in the script
use Database name
exec sp_who -- if you need to check who have been using the database.
From a picture . Sured, the database is in use.



2. Stop Service of Application to use the MS SQL server 2005 | Express | 2008





3. Run Restore against . I have sured , you can restore the database MS SQL 2005 ,Express , 2008