Link to home
Start Free TrialLog in
Avatar of Moiz Saifuddin
Moiz Saifuddin

asked on

DataColumn Add

I have this statement where custDs is the dataset I populate and then am trying to add a column of string type to the

custds.tables(0).Columns.Add("Total",system.type.gettype("system.string"))

but im getting this error on runtime,any ideas since my syntax or order is

System.ArgumentNullException: 'dataType' argument cannot be null. Parameter name: dataType at System.Data.DataColumn..ctor(String columnName, Type dataType, String expr, MappingType type) at System.Data.DataColumnCollection.Add(String columnName, Type type) at ASP.moiz_aspx.Button1_Click(Object sender, EventArgs e)

cn.Open()

				Dim sqlstring as String ="select * from persons"

	Dim sql1command as sqlcommand 
				sql1command = new sqlcommand(sqlstring,cn)
				Dim custDA As SqlDataAdapter = New SqlDataAdapter("select * from persons", cn)
				Dim custDS As DataSet = New DataSet()

				custDA.Fill(custDS, "persons")

Open in new window

Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Try using

custds.tables(0).Columns.Add("Total", GetType(String))
ASKER CERTIFIED SOLUTION
Avatar of Asim Nazir
Asim Nazir
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Moiz Saifuddin
Moiz Saifuddin

ASKER

the explicit declaration of the column was key