Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Datareader.read()
Message
From
21/03/2009 22:41:40
Arjun Bagojikop
Dynamic Super Software
Sangli, India
 
 
To
21/03/2009 12:37:59
General information
Forum:
ASP.NET
Category:
Forms
Environment versions
Environment:
VB 9.0
OS:
Windows XP SP2
Network:
Windows XP
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01390223
Message ID:
01390342
Views:
42
thanks Bonnie Berent
just i have changed my source as below. but i am confused ,when i am create a new procedure for sub do while it work fine .please see the following syntax and suggest me why it is working like this


Private Sub sendtoWeekOffdays(ByVal Type_name As String, ByVal myproc As String, ByVal weelyoff As Decimal)
Dim pf As ProviderFactory = New ProviderFactory
pf.Provider = SqlDataBase.ConnectionType
Dim myconn As IDbConnection = pf.CreateConnection(dssToolKit.myfunc.Appvaribales.ConnectionString)
myconn.Open()

Dim cmd As IDbCommand = pf.CreateCommand(myproc, myconn)
cmd.CommandType = CommandType.StoredProcedure

Dim params As IDbDataParameter
params = pf.CreateDataParameter("@type", Type_name)
params.DbType = DbType.String
cmd.Parameters.Add(params)

Try
Dim dr As IDataReader = cmd.ExecuteReader


Dim weekoffday As Integer
Dim lemp_code As String

Do While dr.Read()
weekoffday = 6 - dr.Item("week_off_day")
lemp_code = dr.Item("emp_unique_code")
If weelyoff = 1 Then
Weekoffdates(lemp_code, weekoffday, weelyoff, 0)
Else
Dim off_days As Integer = dr.Item("off_days")
Weekoffdates(lemp_code, weekoffday, weelyoff, off_days)
End If
Loop

Catch ex As Exception
MsgBox(ex.Message)

End Try

End Sub
Private Sub Weekoffdates(ByVal lemp_code As String, ByVal weekoffday As Integer, ByVal weeklyoff As Decimal, ByVal off_days As Integer)
Dim wfdt As Date = DateTimePicker1.Text
Dim wtdt As Date = DateTimePicker2.Text
Dim offdate As Date = wfdt.Date
offdate = offdate.Date.AddDays(Weekday(offdate) + weekoffday - 1)
If weeklyoff = 1 Then
Do While offdate <= wtdt.Date
updateweekoffday(offdate, lemp_code, weeklyoff)
offdate = offdate.Date.AddDays(7)
Loop
ElseIf weeklyoff = 0.5 Then
updatehalfoffdays(offdate, lemp_code, weeklyoff, off_days)
End If


End Sub
Private Sub updateweekoffday(ByVal mydate As Date, ByVal emp_code As String, ByVal off_day As Decimal)
Dim csql As String = ""
' csql = "delete from Employee_week_offdays where emp_unique_code='" + emp_code + "' and week_off_day='" + mydate.ToString + "'" + Keys.Enter.ToString
csql = csql + "insert into Employee_week_offdays (emp_unique_code,week_off_date,off_day) " + _
"values('" + emp_code + "','" + mydate.ToString + "'," + off_day.ToString + ")"
Dim pf As ProviderFactory = New ProviderFactory
pf.Provider = SqlDataBase.ConnectionType
Dim myconn As IDbConnection = pf.CreateConnection(dssToolKit.myfunc.Appvaribales.ConnectionString)
Dim cmd As IDbCommand = pf.CreateCommand(csql, myconn)
myconn.Open()
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message)
End Try
myconn.Close()
End Sub
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform