0

hi

i'm tryin to get data from my windows form that is 1st stored in a dataset then stored later in a local database(.sdf). this is the code i'm trying to use on the save button clock event.

Dim houseType As String = me.housingType.selectedValue
Dim desc As String = Me.housingDescription.Text

Dim newRow As DataRow = TMSDataSet

......... my 1st problem is here because i get errors when i try to call the new row method.

my 2nd problem is more of a question. Do i have to always insert my form data in a dataset before storing it in the database?

2
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by danielagaba
0

danielagaba,
You must have to use .mdf (sql server database) not .sdf(sql server database compact).

0

i'm abit confused. i'd read that for windows app development, a local database (.sdf) is better if making an app with its own internal database. Could explain just abit more?
will i still need the dataset?

0

Compact sql server (.sdf) is used with device application. Use .mdf (server database) for web, window and other development. Of course you need a DataSet.

0

thanx a bunch. But i still cant get my data inserted into the dataset.
At the point where i declare a datarow ( Dim dr As DataRow = DataSet.DataTable.NewRow), it brings an error saying "reference to a non-shared member required object reference"

0

Here is code for your concern,

Dim Cn as New SqlConnection("connection string....")
  Dim Adp as new SqlDataAdapter("select * fromTableName",Cn)
  ...
  Dim Ds as New DataSet
  Adp.Fill(Ds,"TableName")
  Dim dr as DataRow
  dr=Ds.Tables("TableName").NewRow()
  dr(0)=10
  dr(1)="Mr. A"
  ....
  Ds.Tables("TableName").Rows.Add(dr)
  Adp.Update(Ds,"TableName")
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.