Try : cn.Open() : Catch ex As Exception : End Try
Try : ds.Tables.Remove("contratoarrendatario") : Catch ex As Exception : End Try
mida = New SqlDataAdapter("select * from contratoarrendamiento", cn)
mida.Fill(ds, "contratoarrendamiento")
dr = ds.Tables("contratoarrendamiento").NewRow
dr(0) = Int(txtnumero.Text)
dr(1) = Int(txtgarantia.Text)
dr(2) = Date.Today
dr(3) = pinmeses.Value
dr(4) = dtpfechain.Value
dr(5) = CDate(txtfechafin.Text)
dr(6) = cbotipo.SelectedIndex
dr(7) = cbluz.Checked
dr(8) = txtguardaren.Text
dr(9) = 1
dr(10) = "yo"
ds.Tables("contratoarrendamiento").Rows.Add(dr)
mida.Update(ds, "contratoarrendamiento")