table insertion problem

getnitha

Member
Joined
Jul 16, 2007
Messages
14
Programming Experience
1-3
hai

i got a table having the structure as

D_EVENT_DATE S_USER_ID N_EVENT


08/02/07 08:01:46 R12 16
08/02/07 13:01:58 R12 18
08/02/07 15:02:06 R12 19
08/02/07 20:02:15 R12 17
08/03/07 08:30:00 120 16
08/03/07 13:42:14 120 18
08/03/07 16:22:35 120 19
08/03/07 19:00:49 120 17


I NEED TO RETREIVE THIS WHOLE DATA AND INSERT INTO NEW TABLE
ITS FORMAT IS LIKE THIS

User_ID PUNCH_DATE TIME_IN BREAK_OUT BREAK_IN TIME_OUT
R12 08/02/07 08:01:46 13:01:58 15:02:06 20:02:15
120 08/03/07 08:30:00 13:42:14 16:22:35 19:00:49


can anyone please help me to solve this


my code is like this

<code>

Dim darold As DataRow
countCmd = New SqlCommand("SELECT T_TNA_LOG.S_USER_ID , T_TNA_LOG.N_EVENT, T_TNA_LOG.D_EVENT_DATE FROM T_TNA_LOG ", Conn12)
cmdCount = New SqlDataAdapter(countCmd)
cmdCount.Fill(cmdDs)

For Each darold In cmdDs.Tables(0).Rows
Select Case (darold(2))

Case 16
AttendenceReport.TextBox5.Text = darold(2).ToString().Substring(9, 8)
Case 18
AttendenceReport.TextBox7.Text = darold(2).ToString().Substring(9, 8)
Case 19
AttendenceReport.TextBox8.Text = darold(2).ToString().Substring(9, 8)
Case 17
AttendenceReport.TextBox6.Text = darold(2).ToString().Substring(9, 8)

Dim cmdSql As New SqlCommand
Conn1.ConnectionString = connString
Conn1.Open()
sql1 = "insert into ATTENDENCE_REPORT(User_ID,Punch_Date,Time_In,Break_Out,Break_In,Time_Out) values ('" + darold(0) + "','" + darold(2).ToString().Substring(0, 8) + "','" + AttendenceReport.TextBox5.Text + "','" + AttendenceReport.TextBox7.Text + "','" + AttendenceReport.TextBox8.Text + "')"
cmdSql = New SqlCommand(sql1, Conn1)
cmdSql.ExecuteNonQuery()

Conn1.Close()
End Select
Next


</code>
 
create a new datarow off the new table dataset

U need to have visual components binded to use this drag and drop ur datagridview into your form
VB.NET:
dim dataRow as dataset.TableNameRow
dataRow= Me.dataset.TableName.NewTableNameRow()

With dataRow
.User_ID = 'ur data
.PUNCH_DATE = 'ur data
.TIME_IN = 'ur data
.BREAK_OUT = 'ur data
.BREAK_IN = 'ur data
.TIME_OUT = 'ur data
end with

dataset.tablename.rows.add(dataRow)
TableNameDataAdapter.update(dataset.tableName)
 
Wel, if you want to borrow someone else's brain you can make a posting on RentACoder or something.. Take a few minutes out to read up on pivot though..
 
Back
Top