G
Guest
hey guys, for so long i've been using the Server Explorer to make the connection, config
the adapter and the dataset (just like i was taught in school), but that's not really the real world.
so, i started doing this all in code, which is great.
but, it means that the table, columns arent really known until runtime.
now, i have no problem filling a datagrid, HOWEVER a simple little for loop like:
Dim info As String
Dim i as Integer
For i = 0 To (Ds.Cont_Payroll.Count - 1)
info += (Ds.Cont_Payroll(i).Empl_id) & _
(Ds.ContPayroll(i).Reg_Hours)
Next i
messagebox.show(info.tostring)
it's not happening. i've declared DS as a dataset.then myDa as my dataadapter
and the sql string.
im sure there's something im missing.
any help or links / references to this subject would be greatly appreciated.
here's the code (sub proc) that handles the datagrid:
Private Sub export_vac()
Dim ds As New DataSet
Dim sql, empl, adoe, adate, adate2 As String
empl = UCase(txtEmpl.Text)
adate = daOne.Text
adate2 = daTwo.Text
'search export for vac doe's
Try
sql = "Select empl_id, NVL(reg_hours,0)as Reg,NVL(reg_rate,0)as Rate,NVL(doe,0)as Doe,NVL(neg_earn_ind,0)as Neg,ppe as Ppe,NVL(process_type,0) as Type,Balance_date as Bal_Dt,cheque_date as Ck_Dt,NVL(ot_code,0)as Ot,NVL(ot_hours,0)as Ot_Hrs,NVL(ot_rate,0)as Ot_Rt from cont_payroll where process_type ='P' and empl_id = '" & empl & "' and doe IN ('10','2A') and ppe between to_date('" & adate & "','mm/dd/yyyy') and to_date('" & adate2 & "','mm/dd/yyyy') order by ppe"
Dim oracon As New OracleConnection("Server=atserver;Uid='" & user & "';Pwd='" & pwd1 & "'")
oracon.Open()
ds.Clear()
ds.EnforceConstraints = False
Dim myCmd As New OracleCommand
myCmd.Connection = oracon
myCmd.CommandText = sql
myCmd.CommandType = CommandType.Text
Dim myDa As New OracleDataAdapter(myCmd)
myDa.Fill(ds, "Cont_Payroll")
If ds.Tables.Count = 0 Then
MessageBox.Show("nothing found")
ElseIf ds.Tables.Count >= 1 Then
DataGrid1.DataSource = ds.Tables(0)
Else
End If
oracon.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
as Usual thanks
rik
**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
the adapter and the dataset (just like i was taught in school), but that's not really the real world.
so, i started doing this all in code, which is great.
but, it means that the table, columns arent really known until runtime.
now, i have no problem filling a datagrid, HOWEVER a simple little for loop like:
Dim info As String
Dim i as Integer
For i = 0 To (Ds.Cont_Payroll.Count - 1)
info += (Ds.Cont_Payroll(i).Empl_id) & _
(Ds.ContPayroll(i).Reg_Hours)
Next i
messagebox.show(info.tostring)
it's not happening. i've declared DS as a dataset.then myDa as my dataadapter
and the sql string.
im sure there's something im missing.
any help or links / references to this subject would be greatly appreciated.
here's the code (sub proc) that handles the datagrid:
Private Sub export_vac()
Dim ds As New DataSet
Dim sql, empl, adoe, adate, adate2 As String
empl = UCase(txtEmpl.Text)
adate = daOne.Text
adate2 = daTwo.Text
'search export for vac doe's
Try
sql = "Select empl_id, NVL(reg_hours,0)as Reg,NVL(reg_rate,0)as Rate,NVL(doe,0)as Doe,NVL(neg_earn_ind,0)as Neg,ppe as Ppe,NVL(process_type,0) as Type,Balance_date as Bal_Dt,cheque_date as Ck_Dt,NVL(ot_code,0)as Ot,NVL(ot_hours,0)as Ot_Hrs,NVL(ot_rate,0)as Ot_Rt from cont_payroll where process_type ='P' and empl_id = '" & empl & "' and doe IN ('10','2A') and ppe between to_date('" & adate & "','mm/dd/yyyy') and to_date('" & adate2 & "','mm/dd/yyyy') order by ppe"
Dim oracon As New OracleConnection("Server=atserver;Uid='" & user & "';Pwd='" & pwd1 & "'")
oracon.Open()
ds.Clear()
ds.EnforceConstraints = False
Dim myCmd As New OracleCommand
myCmd.Connection = oracon
myCmd.CommandText = sql
myCmd.CommandType = CommandType.Text
Dim myDa As New OracleDataAdapter(myCmd)
myDa.Fill(ds, "Cont_Payroll")
If ds.Tables.Count = 0 Then
MessageBox.Show("nothing found")
ElseIf ds.Tables.Count >= 1 Then
DataGrid1.DataSource = ds.Tables(0)
Else
End If
oracon.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
as Usual thanks
rik
**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...