While Creating DataSet on Red Colored statement error occured which is Mentioned in Green Color....(A'm using Visual Studio 2005 and SQL Server 2005) Please Help......

'Create New DataSet
Dim ds As New DataSet("DataSetVendorInfo")
'Create a new Table and Columns
Dim dTable As New DataTable("Vendors")
dTable.Columns.Add("Ven_ID", System.Type.GetType("System.Int32"))

dTable.Columns.Add("FName", System.Type.GetType("System.String"))

dTable.Columns.Add("LName", System.Type.GetType("System.String"))

dTable.Columns.Add("Ven_Addr", System.Type.GetType("System.String"))

dTable.Columns.Add("Ven_City", System.Type.GetType("System.String"))

dTable.Columns.Add("Ven_State", System.Type.GetType("System.String"))

dTable.Columns.Add("PinCode", System.Type.GetType("System.String"))

dTable.Columns.Add("EmailID", System.Type.GetType("System.String"))

dTable.Columns.Add("Contact_No", System.Type.GetType("System.String"))

dTable.Columns.Add("Fax_No", System.Type.GetType("System.String"))

dTable.Columns.Add("Years", System.Type.GetType("System.String"))

dTable.Columns.Add("Months", System.Type.GetType("System.String"))

dTable.Columns("Ven_ID").AutoIncrement = True
ds.Tables.Add("Vendors")

'Define Primary Key
Dim keys() As DataColumn = (ds.Tables("Vendors").Columns("Ven_ID"))
Here Error is: Value of Type 'System.Data.DataColumn can not be Converted to '1-dimensional Array of 'System.Data.DataColumn

ds.Tables("Vendors").PrimaryKey = keys

Dim dr As DataRow = dTable.NewRow

dr(0) = txtFName.Text
dr(1) = txtLName.Text
dr(2) = txtAddress.Text
dr(3) = ddlCity.Text
dr(4) = ddlState.Text
dr(5) = txtPinCode.Text
dr(6) = txtEmail.Text
dr(7) = txtContact.Text
dr(8) = txtFax.Text
dr(9) = ddlYears.Text
dr(10) = ddlMonths.Text

dTable.Rows.Add(dr)

You cannot make an array out of a datacolumn. You would have to set it this way:

Dim keys() As String = (ds.Tables("Vendors").Columns("Ven_ID"))

Or remove the () and keep it as a DataColumn.

You cannot make an array out of a datacolumn. You would have to set it this way:

Dim keys() As String = (ds.Tables("Vendors").Columns("Ven_ID"))

Or remove the () and keep it as a DataColumn.

I have used code instructed by u....
i.e. Dim keys() As String = (ds.Tables("Vendors").Columns("Ven_ID"))
It is giving Error:Value of type 'System.Data.DataColumn' can not be converted to 1-diamensional array of String

Try adding this at the end. Not sure if it will work, but it might:

Dim keys() As String = (ds.Tables("Vendors").Columns("Ven_ID")).ToString()

Or you might have to loop through each row within that column, and bind it to Keys that way.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.