Click here to Skip to main content
15,888,802 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Stopping a running process (vb2005) while updating a progress bar Pin
Vivek Narayanan15-Aug-07 1:02
Vivek Narayanan15-Aug-07 1:02 
AnswerRe: Stopping a running process (vb2005) while updating a progress bar [modified] Pin
GuyThiebaut15-Aug-07 1:44
professionalGuyThiebaut15-Aug-07 1:44 
GeneralRe: Stopping a running process (vb2005) while updating a progress bar Pin
MartyK200715-Aug-07 3:19
MartyK200715-Aug-07 3:19 
GeneralRe: Stopping a running process (vb2005) while updating a progress bar Pin
GuyThiebaut15-Aug-07 4:00
professionalGuyThiebaut15-Aug-07 4:00 
GeneralRe: Stopping a running process (vb2005) while updating a progress bar Pin
Vivek Narayanan15-Aug-07 5:05
Vivek Narayanan15-Aug-07 5:05 
QuestionLoop For Datatable Pin
ejaz_pk14-Aug-07 22:24
ejaz_pk14-Aug-07 22:24 
AnswerRe: Loop For Datatable Pin
_mubashir14-Aug-07 22:31
_mubashir14-Aug-07 22:31 
QuestionRe: Loop For Datatable [modified] Pin
ejaz_pk14-Aug-07 22:38
ejaz_pk14-Aug-07 22:38 
Here is coding for the application

I am getting error message when click on button1_click event


Imports System.Data
Imports System.Data.OleDb

Partial Class _Default
Inherits System.Web.UI.Page

Dim MYDT As DataTable
Dim mydatatable As DataTable

Private Function CreateDataTable() As DataTable
mydatatable = New DataTable()

Dim myDataColumn As DataColumn

myDataColumn = New DataColumn()
myDataColumn.DataType = Type.GetType("System.String")
myDataColumn.ColumnName = "id"
myDataTable.Columns.Add(myDataColumn)

myDataColumn = New DataColumn()
myDataColumn.DataType = Type.GetType("System.String")
myDataColumn.ColumnName = "username"
myDataTable.Columns.Add(myDataColumn)

myDataColumn = New DataColumn()
myDataColumn.DataType = Type.GetType("System.String")
myDataColumn.ColumnName = "firstname"
myDataTable.Columns.Add(myDataColumn)

myDataColumn = New DataColumn()
myDataColumn.DataType = Type.GetType("System.String")
myDataColumn.ColumnName = "lastname"
myDataTable.Columns.Add(myDataColumn)

Return myDataTable
End Function

Private Sub AddDataToTable(ByVal username As String, ByVal firstname As String, ByVal lastname As String, ByVal myTable As DataTable)
Dim row As DataRow

row = myTable.NewRow()

row("id") = Guid.NewGuid().ToString()
row("username") = username
row("firstname") = firstname
row("lastname") = lastname

myTable.Rows.Add(row)

End Sub

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
If Me.IsPostBack = False Then
MYDT = New Data.DataTable()
MYDT = CreateDataTable()
Session("myDatatable") = MYDT

Me.GridView1.DataSource = (CType(Session("myDatatable"), Data.DataTable)).DefaultView
Me.GridView1.DataBind()
End If
End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

If Me.TextBox1.Text.Trim() = "" Then

Me.Label1.Text = "You must fill a username."
Return

Else


Dim x As DataRow

For Each x In mydatatable.Rows
If x.Item(1).ToString = Me.TextBox1.Text Then
Me.Label1.Text = "Exist"
End If
Next

AddDataToTable(Me.TextBox1.Text.Trim(), Me.TextBox2.Text.Trim(), Me.TextBox3.Text.Trim(), CType(Session("myDatatable"), DataTable))

Me.GridView1.DataSource = CType(Session("myDatatable"), DataTable).DefaultView

Me.GridView1.DataBind()

Me.TextBox1.Text = ""
Me.TextBox2.Text = ""
Me.TextBox3.Text = ""
Me.Label1.Text = ""

Me.TextBox1.Focus()

End If
End Sub
End Class




-- modified at 5:43 Wednesday 15th August, 2007
AnswerRe: Loop For Datatable Pin
Christian Graus15-Aug-07 0:25
protectorChristian Graus15-Aug-07 0:25 
GeneralRe: Loop For Datatable Pin
ejaz_pk15-Aug-07 2:14
ejaz_pk15-Aug-07 2:14 
Questionhow to call a class Pin
eyes200714-Aug-07 21:19
eyes200714-Aug-07 21:19 
AnswerRe: how to call a class Pin
Taylor Kobani14-Aug-07 23:14
Taylor Kobani14-Aug-07 23:14 
GeneralRe: how to call a class Pin
eyes200714-Aug-07 23:29
eyes200714-Aug-07 23:29 
AnswerRe: how to call a class Pin
Christian Graus15-Aug-07 0:29
protectorChristian Graus15-Aug-07 0:29 
QuestionWhy my .exe program (with winsock) can't run in other computer? Pin
cedonulfi14-Aug-07 19:51
cedonulfi14-Aug-07 19:51 
AnswerRe: Why my .exe program (with winsock) can't run in other computer? Pin
Christian Graus14-Aug-07 20:05
protectorChristian Graus14-Aug-07 20:05 
Questioncombobox in vb.net Pin
enmahdi14-Aug-07 19:41
enmahdi14-Aug-07 19:41 
AnswerRe: combobox in vb.net Pin
Christian Graus14-Aug-07 19:42
protectorChristian Graus14-Aug-07 19:42 
GeneralRe: combobox in vb.net Pin
Salman Sheikh15-Aug-07 0:20
Salman Sheikh15-Aug-07 0:20 
QuestionGet files and folders that Windows is accessing in VB6 [modified] Pin
Yun Bunchhay14-Aug-07 15:35
Yun Bunchhay14-Aug-07 15:35 
AnswerRe: Get files and folders that Windows is accessing in VB6 Pin
Christian Graus14-Aug-07 15:41
protectorChristian Graus14-Aug-07 15:41 
GeneralRe: Get files and folders that Windows is accessing in VB6 Pin
Yun Bunchhay14-Aug-07 16:48
Yun Bunchhay14-Aug-07 16:48 
GeneralRe: Get files and folders that Windows is accessing in VB6 Pin
Dave Kreskowiak15-Aug-07 3:54
mveDave Kreskowiak15-Aug-07 3:54 
QuestionAdding Reference Pin
HelpMePlease!14-Aug-07 11:24
HelpMePlease!14-Aug-07 11:24 
AnswerRe: Adding Reference Pin
Dave Kreskowiak14-Aug-07 12:29
mveDave Kreskowiak14-Aug-07 12:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.