Can anyone explain how it is hapenning

king_salman
12-17-2003, 10:48 PM
hi,
This is the weirdest of things that is hapening.
this uses a access database.the table in database is Citycodes with two columns
Citycode datatype=text,length=7
CityName datatype=text,length=48
i have a oledb dataset named ds,oledb dataadapter ada.ds has six tables
PtclNumbers
MobileNumbers
InternationalNumbers
PtclCityCodes
Country
MobileCompanyCode
now the tables have same name,caption and variable name used in form
i.e
me.MobileCompanyCode
MobileCompanyCode.caption="MobileCompanyCode"
MobileCompanyCode.name="MobileCompanyCode"
In ptclcitycodes table there are two columns
PtclCityCode
PtclCityName
column mapping is element and it is same for all tables.now my application is an mdi application so this ds, and ada are declared in parent form.
Parent forms class is
Public Class MainScreen
In each child form i have declared an private variable myParent.this myparent is of type ptcldatabase.MainScreen where ptcldatabase is my application name space.in one child form that is addNatinalPersonal i have a public function fillcontrol.the pourpouse of fill control is to fill a combobox with city code,and city name
complete code of fill control is given below
Public Function FillControl()
Dim RowCount As Int16 = 0
Me.Cursor.Current = Cursors.WaitCursor
MyParent = Me.MdiParent
With MyParent
Dim commandbiulder As New OleDb.OleDbCommandBuilder(.Ada)
Try
'.Ds.Tables.Clear()
.Ada.SelectCommand = New OleDb.OleDbCommand()
'.Ds.Tables("PtclNumbers").Rows.Clear()
'MsgBox(.Ds.Tables("PtclCityCodes").Columns(0).ColumnName.ToString, MsgBoxStyle.OKOnly)
'MsgBox(.Ds.Tables("PtclCityCodes").Columns(1).ColumnName.ToString, MsgBoxStyle.OKOnly)
' MsgBox(.Ds.Tables("PtclCityCodes").Columns(2).ColumnName.ToString, MsgBoxStyle.OKOnly)
'MsgBox(.Ds.Tables("PtclCityCodes").Columns(3).ColumnName.ToString, MsgBoxStyle.OKOnly)
.Ada.SelectCommand.Connection = .Con
.Ada.SelectCommand.CommandType = CommandType.Text
'.Ada.SelectCommand.CommandText = "Select CityCodes.Citycode,CityCodes.CityName From CityCodes Order By CityCodes.CityName"
.Ada.SelectCommand.CommandText = "Select * From CityCodes "
.Con.Open()
' MsgBox(.Ds.Tables("PtclCityCodes").Rows.Count.ToString, MsgBoxStyle.OKOnly)
.Ada.Fill(.Ds, "PtclCityCodes")
' MsgBox((.Ds.Tables("PtclCityCodes").Columns.Count.ToString), MsgBoxStyle.OKOnly)
Try
For RowCount = 0 To .Ds.Tables("PtclCityCodes").Rows.Count - 1
Me.CmbCityCodeName.Items.Add((.Ds.Tables("PtclCityCodes").Rows(RowCount).Item(1).ToString) & " " & (.Ds.Tables("PtclCityCodes").Rows(RowCount).Item(0).ToString))
Next
' For RowCount = 0 To .Ds.Tables("PtclCityCodes").Columns.Count - 1
'Me.CmbCityCodeName.Items.Add((.Ds.Tables("ptclcitycodes").Columns(RowCount).ColumnName.ToString))
'Next RowCount
Catch eselectexception As Exception
MsgBox(eselectexception.ToString, MsgBoxStyle.Critical, "Fill Error")
End Try
Catch eselectexception As Exception
MsgBox(eselectexception.ToString, MsgBoxStyle.Critical, "Fill Error")
Finally
.Con.Close()
End Try
End With
Me.Cursor.Current = Cursors.Default
End Function

Now what happens is that when fill control is called it creates two new columns in ptclcitycodes whose names are CityCode,Cityname which means the table looks like this
Table PtclCityCodes
Column PtclCityCode
Column PtclCityName
Column CityCode
Column CityName
the same columns which are present in database table and all the records returned have been stored in these two columns now i am not creating any new columns in dataset's table neither i have used the addrange so how it is that these columns are created.i have checked all the code of application in other forms.can any one help.One thing more i have used the same algorithm in 2 other forms and it worked why it is troubling here i seriously do not know.
if you notice the message boxes i used them to try and find the cause.the language as you migth have noticed is vb.net
and frame work is 1.0.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum