VB.NET에서 ""문자열을 0으로 치환할때 사용하는 방법

1. k=Val("")
2. Integer.TryParse("",k)

Posted by leeyongwan
,
VB.NET에서 MySQL을 연결하여 사용하여야할 때가 있습니다. VB.NET을 어느정도 아신다고 가정하고 간단하게 설명해놓은 버전입니다.

1. MySQL Connector 를 설치합니다.


에서 ADO.NET Driver for MySQL 드라이버를 받아 설치합니다. 설치하면 
C:\Program Files\MySQL\MySQL Connector Net 6.2.4\Assemblies 폴더에 
MySql.Data.dll
파일이 생성됩니다.

2. 생성된 dll 파일을 레퍼런스에 추가합니다.

3. 코드를 다음과 같이 작성합니다.
Imports MySql.Data.MySqlClient

Dim MySQL_CS As String = "Server=111.111.111.111;" & _
"Database=dbname;Uid=id;Pwd=password;"
Dim SQL As String = "SELECT * FROM table1"
Dim myConn As New MySqlConnection(MySQL_CS)
Private myBindingSource As New BindingSource
Dim myCmd As New MySqlCommand

myCmd.Connection = myConn
myCmd.CommandText = SQL
myConn.Open()
Dim myReader As MySqlDataReader = myCmd.ExecuteReader

'table
myBindingSource.DataSource = myReader
DataGridView1.DataSource = myBindingSource
myConn.Close()



Posted by leeyongwan
,


Dim ad As String = "http://www.mydomain.com/"
Dim fn As String = "Alien 2.bmp"
Using client As New System.Net.WebClient
    client.Credentials = New System.Net.NetworkCredential("id", "pwd")
    client.DownloadFileAsync(ad + fn, "c:\" + fn)
End Using
Posted by leeyongwan
,