[RESOLVED] databinding in adodb connection
Hi,
I am connecting to a foxpro table using adodb connection
Code:
fcn = New ADODB.Connection
fcn.ConnectionString = "provider=VFPOLEDB.1;Data Source= D:\" & shopname
fcn.Open()
Using this I am trying to fill a datagrid values using binding. The value of ts=0
Code:
rst.Open("SELECT ITEM, ORD, INVENTORY FROM INVENT Where ITEM Like '" & itemno & "' ORDER BY ITEM", fcn)
BindingSource1.DataSource = rst
rst.Close()
DataGridView1.Item(17, s).Value = Format((ts / Val(rst(1).Value)), "0.00")
But this statement is not working . I am getting follwoing error
Code:
Following exception occured in the datagridview
System Exceptio: 0.00 is not a valid value for Int32. --> System.formatException: Input string was not in a correct format
But this is working fine for OleDbConnection
Re: databinding in adodb connection
Quote:
0.00 is not a valid value for Int32
Tells you that one of your values says Int32, but seems to be string data
1 Attachment(s)
Re: databinding in adodb connection
I modified te code to
Code:
rst.Open("SELECT lp.ITEM, lp.ORD, INVENT." & qt1 & ", INVENT." & qt2 & ", INVENT." & qt3 & ", INVENT." & qt4 & ", INVENT." & qt5 & ", INVENT." & qt6 & ", INVENT." & qt7 & ", INVENT." & qt8 & ", INVENT." & qt9 & ", " & totquan & ", lp.PRICE, lp.CATEGORY, lp.LINE, lp.QORD FROM INVENT INNER JOIN lp ON INVENT.ITEM_NO = lp.ITEM_NO Where lp.ITEM Like '" & itemno & "' ORDER BY lp.ITEM", fcn)
BindingSource1.DataSource = rst
rst1.Open("SELECT lp.ITEM as totitem, lp.ORD, INVENT." & qt1 & ", INVENT." & qt2 & ", INVENT." & qt3 & ", INVENT." & qt4 & ", INVENT." & qt5 & ", INVENT." & qt6 & ", INVENT." & qt7 & ", INVENT." & qt8 & ", INVENT." & qt9 & ", " & totquan & ", lp.PRICE, lp.CATEGORY, lp.LINE, lp.QORD FROM INVENT INNER JOIN lp ON INVENT.ITEM_NO = lp.ITEM_NO Where lp.ITEM Like '" & itemno & "' ORDER BY totitem", fcn)
While Not rst.EOF
If IsDBNull(rst1(11).Value) = False And IsDBNull(rst1(15).Value) = False And Val(rst1(15).Value) <> 0 Then
ts = (rst1(15).Value) - (rst1(11).Value)
ts = ts * 100
DataGridView1.Item(17, s).Value = Format((ts / Val(rst1(15).Value))) ', "0.00")
Else
DataGridView1.Item(17, s).Value = "No T/O"
End If
s = s + 1
If s > DataGridView1.RowCount Then
Exit While
End If
rst1.MoveNext()
End While
rst1.close()
rst.Close()
I am getting multiple exceptions
I have attached a screen shot of the errors
Re: databinding in adodb connection
I feel like the problem is with the data binding using ADODB connection.
Code:
fcn = New ADODB.Connection
fcn.ConnectionString = "provider=VFPOLEDB.1;Data Source= D:\" & foldrname
fcn.Open()
rst = New ADODB.Recordset
Re: databinding in adodb connection
The data binding done is wrong. if any one know the syntax for binding source , please let me know
Here is what i tried with
Code:
fcn = New ADODB.Connection
fcn.ConnectionString = "provider=VFPOLEDB.1;Data Source= D:\" & foldrname
fcn.Open()
rst = New ADODB.Recordset
rst.open("select * from table" ,fcn)
BindingSource1.DataSource = rst
DataGridFirst.ReadOnly = True
DataGridFirst.DataSource = BindingSource1
rst.Close()
Re: databinding in adodb connection
I have a link in my signature, showing the correct way to do it. Here: http://code.msdn.microsoft.com/vbsamples/
Re: databinding in adodb connection
I changed from adodb to oledb and now its working
Code:
newn = New OleDbConnection
newn.ConnectionString = "provider=VFPOLEDB.1;Data Source= D:\" & shopname
newn.Open()
Thanks dglienna for the support provided