Visual Basic Development Bookmark and Share   
 Home > Visual Basic Language > dbnull in textboxt to datagridview
 

dbnull in textboxt to datagridview

hi everbody.........

this code i pick from grauva khanna...
it working..but for one coulmn only..
my question is ..how to manipulate every column with dbnull.value

      'If TextBox1.Text.Trim = "" And TextBox2.Text.Trim = "" And TextBox3.Text.Trim = "" And TextBox4.Text.Trim = "" Then
        'DT.Rows.Add(DBNull.Value, DBNull.Value, DBNull.Value, DBNull.Value)

        'ElseIf Not TextBox1.Text.Trim = "" And Not TextBox2.Text.Trim = "" And Not TextBox3.Text.Trim = "" And Not TextBox4.Text.Trim = "" Then
        'DT.Rows.Add(TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text)

        'ElseIf TextBox1.Text.Trim = "" And Not TextBox1.Text.Trim = "" And TextBox2.Text.Trim = "" And Not TextBox2.Text.Trim = "" Then
        'DT.Rows.Add(DBNull.Value, TextBox1.Text, DBNull.Value, TextBox4.Text)

        '' ElseIf Not TextBox3.Text.Trim = "" And TextBox3.Text.Trim = "" And Not TextBox4.Text.Trim = "" And TextBox4.Text.Trim = "" Then
        'DT.Rows.Add(TextBox1.Text, DBNull.Value, TextBox3.Text, DBNull.Value)

        ' End If
thank.............
mipakteh  Tuesday, November 24, 2009 10:21 AM
Whichever the column gives error just change it as "DBNull.Value.Tostring"

U.PARANTHAMAN
Paramu  Wednesday, November 25, 2009 10:08 AM

Simply you can add a row and no need to mention with column names...

dim My_Row as datarow

For F11 As Integer = 0 To 40

My_Row = Dt.NewRow

Dt.Rows.Add(My_Row)

Next


U.PARANTHAMAN
Paramu  Tuesday, November 24, 2009 10:43 AM
thank Paramu....for your feedback


i have 13 column in dtgridview and 13 textbox for key in data.

BUT sometimes i need the certain cell(column) is NULL or EMPTY

ERROR is coming whenthe textbox is NULL ..error message"could'not store

let said the textbox7 is NULL for row1 and NOT null at row2 ..(how to assign the my textbox.text to My_Row)

give idea..
mipakteh  Wednesday, November 25, 2009 8:52 AM
Whichever the column gives error just change it as "DBNull.Value.Tostring"

U.PARANTHAMAN
Paramu  Wednesday, November 25, 2009 10:08 AM
hai paramu........
give example..please.
mipakteh  Thursday, November 26, 2009 6:41 AM

You can use google to search for other answers

Custom Search

More Threads

• don't understand readonly and writeonly property in VB
• Best way to handle text files?
• VB 5
• Import from HTML table
• Launch Registry Permissions Dialog box
• Not opening more then one child form.
• Need my help with my panles please.
• Boolean Explanation Please!!!
• VB.NET 2003 move files across volumes
• please help me !