Think is should be simple but carn`t find info:(

  • Thread starter Thread starter MadCrazyNewbie
  • Start date Start date
Hi Mad,

That was this part
The OleDB needs some litle changes. the Select string becomes for OleDB
(access) something as.
"SELECT * FROM Mytable WHERE Fax = ?"

Should be your table of course and the right name for the faxId field in
your accessfile.

And than this right before the fill

Also with the right name (this is case sensetive) for the faxId.

odaFaxMeterReadings.SelectCommand.Parameters.Add(New OleDbParameter("Fax",
OleDbType.Char)).Value = FaxId


http://msdn.microsoft.com/library/d...eDbOleDbParameterCollectionClassAddTopic2.asp

Than it should give only the one fax you selected,

Cor
 
Cor,

Do I need to put the "SELECT * FROM Faxs WHERE Fax = FaxID" in My
DataAdapter on Form 2?

On my Form 2 I`ve created 2 x Dataadapters odaFaxs, and odaFaxMeterReadings
and bound them in my DS.

Now on my form 2 x I have:

Me.odcFaxMeterReadings.Open()
odaFaxMeterReading.SelectCommand.Parameters.Add(New
OleDb.OleDbParameter("Checked", OleDb.OleDbType.Char)).Value = FaxId
Me.odaFaxs.Fill(dsFaxMeterReadings)
Me.odaFaxMeterReading.Fill(dsFaxMeterReadings)
Catch fillException As System.Exception
Throw fillException
Finally
Me.odcFaxMeterReadings.Close()

Is this Correct? or im I understanding wrong?

When I click on my FaxMeterReading Button on Form one I get a error saying
"No Value Given for one or more Parameters"

MAny Thanks Again
MCN
 
Hi Mad,

It is in this approach important that in Form2 only the selected fax is
readed.

So I am talking about the selectionstring from that, somewhere there has to
be a selectionstring in that form, because you fill it from that, ( I assume
you have no shared database class now).

And that is than the one for which for the faxes this WHERE part in my
opinion should be added.

Cor
 
Sorry Cor,

I think im lost again:( Do you mean:

On Both My DataAdapeters use the following "SELECT * From <TABLENAME>

Then in my code:

Dim sqlFaxMeterReadings As sqlString
sqlFaxMeterReadings = "SELECT * FROM Faxs WHERE Fax = FaxID"

If the above is correct and im not getting confused, how do I tell it to use
that on my .Fill or .Open commands?

Many Thanks
MCN
 
Hi Max,

show those selectstrings in your dataadapters as they are now (only form2),
than I think I get more information

Cor
 
Cor,

I don`t get what you mean? Sorry i feel really Stupid now:(

On My odaFaxs I have "Select * From Faxs", on my odaFasMeterReadings I have
"Select * From FaxReadings" Now

Now everything works fine when I click on my button, it just lists all the
Meter Readings for all Faxs Not just the one I select.

Now have I got this correct? on My Form1 the command
"Me.dgdFaxs.Item(dgdFaxs.CurrentRowIndex, 0).ToString" taes my current
position in my Datagrid on my form 1 and sends it to a string?

Then form2 has "Public FaxsID As String" which then finds the String sent
from Form 1 and loads it?

Then: "odaFaxMeterReading.SelectCommand.Parameters.Add(New
OleDbParameter("Checked", OleDbType.Char)).Value = FaxsID" Uses the Value to
Load the Data?

I was Thinking I need something like:
OleDbParameter("Checked", OleDbType.Char)).Value = FaxsID

But Im Not Sure

I`ve Also include my most recent Code incase its an error in that

Many Many Thanks Cor, Sorry to be such a pain
Thanks
MCN

**My Button Click Code is:
Private Sub btnFaxsMeterReadings_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnFaxsMeterReadings.Click
Dim LoadFaxMeterReadings As New frmFaxMeterReadings()
LoadFaxMeterReadings.FaxsID = Me.dgdFaxs.Item(dgdFaxs.CurrentRowIndex,
0).ToString
LoadFaxMeterReadings.ShowDialog()
End Sub

**My Code on Form2 is now:
Public FaxsID As String
Public Property RowHolder() As DataRow
Get
Return _RowHolder
End Get
Set(ByVal Value As DataRow)
_RowHolder = Value
End Set
End Property
Public Sub New(ByVal _Holder As DataRow)
Me.RowHolder = _Holder
End Sub
Private Sub frmFaxMeterReadings_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load
mlLoading = True
Try
dsFaxMeterReadings.EnforceConstraints = False
Try
Me.odcFaxMeterReadings.Open()OleDbParameter("Checked", OleDbType.Char)).Value = FaxsID
Me.odaFaxs.Fill(dsFaxMeterReadings)
Me.odaFaxMeterReading.Fill(dsFaxMeterReadings)
Catch fillException As System.Exception
Throw fillException
Finally

Me.odcFaxMeterReadings.Close()
End Try
Catch eLoad As System.Exception
System.Windows.Forms.MessageBox.Show(eLoad.Message)
Finally
mlLoading = False
End Try
End Sub
 
Hi Simon,

The only thing you should change in my opinion is now that words MAD that
should be the name of the field that holds the faxid in the table
FaxReadings and than exactly in the right case as it is in the access
table..

odaFasMeterReadings
"Select * From FaxReadings WHERE MAD = ?"


Private Sub frmFaxMeterReadings_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
mlLoading = True
odaFaxMeterReadings.SelectCommand.Parameters.Add(New OleDbParameter("MAD",
OleDbType.Char)).Value = FaxId
'Start of Fill Datasets
Try
dsFaxMeterReadings.EnforceConstraints = False
Try
Me.odcFaxMeterReadings.Open()
'Fill Arciris Roles Datasets
Me.odaFaxMeterReadings.Fill(dsFaxMeterReadings)
Catch fillException As System.Exception
Throw fillException
Finally
Me.odcFaxMeterReadings.Close()
End Try
Catch eLoad As System.Exception
System.Windows.Forms.MessageBox.Show(eLoad.Message)
Finally
mlLoading = False
End Try
'End of Fill Datasets
dim dv as new dataview(dsFaxMeterReadings)
datagrid1.datasource = dv
End Sub

Cor
 
Hey Cor,

I`ve changed my odaFaxsMeterReading DataAdapetr SQL statement to:

Select * From FaxReadings WHERE FaxsID = ?, I`ve also tryed Select * From
FaxReadings WHERE FaxsID = FaxsID as I wondered if the ? was wrong.

If I do the FaxsID = ? I get "? Value Not Specified" Error, if i do: FaxsID
= FaxsID I get:

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an
object.
at System.Windows.Forms.DataGrid.AddNewRow()
at System.Windows.Forms.DataGridAddNewRow.OnEdit()
at System.Windows.Forms.DataGrid.Edit(String instantText)
at System.Windows.Forms.DataGrid.Edit()
at System.Windows.Forms.DataGrid.OnEnter(EventArgs e)
at System.Windows.Forms.Control.NotifyEnter()
at System.Windows.Forms.ContainerControl.UpdateFocusedControl()

Any Ideas?

Thanks
MCN

Now when I click on my button I get
 
Hi Mad,
If I do the FaxsID = ? I get "? Value Not Specified"

That value should be specified with this, did you change that MAD also to
"FaxsID"?

odaFaxMeterReadings.SelectCommand.Parameters.Add(New OleDbParameter("MAD",
OleDbType.Char)).Value = FaxId

Cor
 
Hey Cor,

Yes on my DataAdapter I have: Select * From FaxReadings WHERE FaxsID =
FaxsID

I also Have: odaFaxMeterReadings.SelectCommand.Parameters.Add(New
OleDbParameter("FaxsID", OleDbType.Char)).Value = FaxsID

Is it worth me sending you my Code, you might be able to see the problem
easier?

Thanks
MCN
 
Hi Mad,

My adres is in my mail it is original however notmyfirstname, only my
lastname.

Cor
 
Many Thanks to Cor, Who has helped me with the problem Offline (After about
30 e-mails)

Many Thanks Again - Cor

Thanks
MCN
 
Back
Top