Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dim ds as new DataSet
dim bs as new BindingSourse
Dim dt As New DataTable("Test")


Dim dob As New DataColumn("dob", System.Type.GetType("System.DateTime"))' I try to do it, but it seem this code does't work  
dt.Columns.Add(dob)
ds.Tables.Add(dt)

  bs.DataSource = ds.Tables("Test")
Textbox1.DataBindings.Add("Value", bs, "dob")


help me please.

thanks
Posted
Updated 26-Mar-12 6:14am
v3
Comments
[no name] 26-Mar-12 12:16pm    
You need to give more details than "this code doesn't work" if you expect an answer. What doesn't work? Is there an exception?
Dean Oliver 26-Mar-12 12:28pm    
Whats the exception?

1 solution

Let's start from the very elementary things:

Don't use System.Type.GetType("System.DateTime"); use typeof(System.DateTime).

How can you consider the first case maintainable? What if you mistype the type name? The compiler won't be able to check it up. Generally, using any immediate constants like your "System.DateTime" (except something like 0, 1 or null) is very bad for maintenance, even "" should not be used — use string.Empty instead.

—SA
 
Share this answer
 
v2
Comments
ProEnggSoft 26-Mar-12 20:46pm    
Very good advice. +5
Sergey Alexandrovich Kryukov 26-Mar-12 20:51pm    
Thank you.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900