27.2.12

Using WebClient

Hi Everybody,
I would like to explain one of faq within this essay , how we can WebClient object. I am going to explain how we can show web image via WebClient object.


If any question, please feel free to contact me y_turkeli@yahoo.com or
yenerturkeli@v-basic.net.


1-) We are creating a new Windows Application Project 


2-) We are designing this windows form in a similar way to the picture below


3-) We are writing this code


Imports System.IO
Imports System.Net

Public Class Form1
    Dim my_url As String
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        my_url = url_text.Text

        Try

            Dim web_client As New WebClient()

            Dim my_image As Image
            Dim img_stream As New  _
                MemoryStream(web_client.DownloadData(my_url))
            my_image = Image.FromStream(img_stream)

            web_pic.Image = my_image

        Catch ex As Exception
            MessageBox.Show("Error  " & _
             ex.Message, _
                "Download Error" & MessageBoxIcon.Error)
        End Try

    End Sub


End Class

4-) Lets run the application




Have a nice day
Yener Turkeli




20.2.12

Split Image

Hi Everybody,
I would like to explain one of faq within this essay , how we can split image.

If any question, please feel free to contact me y_turkeli@yahoo.com or
yenerturkeli@v-basic.net.

1-) We are creating a new Windows Application Project 


2-) We are designing this windows form in a similar way to the picture below


3-) Timer Settings


4-) We are writing this code


5-) Lets run the application




Have a nice day
Yener Turkeli 

4.2.12

Insert Data via SqlDatASource Programmatically

Hi Everybody,

I would like to explain one of faq within this essay , how we can insert data via SQLDatasource to MSSQL Server Database .

If any question, please feel free to contact me y_turkeli@yahoo.com or
yenerturkeli@v-basic.net.

1-) We are creating a new ASP.NET Empty Web Site 


2-) Add New Web Page


3-) We are designing this windows form in a similar way to the picture below


4-) We are writing this code


Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub reg_btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles reg_btn.Click

        Dim connection_string As String

        connection_string = "Data Source=localhost;Initial Catalog=customers;Persist Security Info=True;User ID=yener;Password=mypassword"

        Dim my_datasource As New SqlDataSource

        my_datasource.ConnectionString = connection_string
        my_datasource.InsertCommand = "INSERT INTO [members] ([number], [fullname], [age], [gender], [email], [city], [country]) VALUES (@number, @fullname, @age, @gender, @email, @city, @country)"

        my_datasource.InsertParameters.Clear()
        With my_datasource
            .InsertParameters.Add("number", number_txt.Text)
            .InsertParameters.Add("fullname", fullname_txt.Text)
            .InsertParameters.Add("gender", gender_drp.Text)
            .InsertParameters.Add("age", age_txt.Text)
            .InsertParameters.Add("email", email_txt.Text)
            .InsertParameters.Add("city", mobile_txt.Text)
            .InsertParameters.Add("country", postcode_txt.Text)
        End With



        Try
            my_datasource.Insert()
            Label1.Text = "Thanks for your registration"
        Catch ex As Exception
            Label1.Text = "Sorry something is wrong"
        End Try


    End Sub
End Class

5-) Lets run the application



Have a great day
yenerturkeli@v-basic.net