Click here to Skip to main content
15,915,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have 1 table factory which has lot_no,group,type,shape,description,pieces,weight_given,issue_dt
as columns
and another 1 table name facsort which has lot_no, group,type,shape,description,pieces,weight_given,issuedt,wt_return and return dt as columns.

now i want to display in gridview only those data whose returned date has not been entered in database.

that is date has been issued but the stones are not returned on return date.

that is which are the stones given but not returned.

can anyone please help me.

i will be obliged.

thanks in advance.
Posted
Comments
sudeshna from bangkok 16-Jul-13 0:15am    
Public Class Form7
Dim cn As New SqlConnection("Data Source=.\INSTANCE;initial catalog=record;user=sa;password=gariahat")
Dim da As New SqlDataAdapter
Dim cmd As New SqlCommand
'Dim dr As New SqlDataReader
Dim ds As New DataSet



Private Sub Form7_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'RecordDataSet.facsort' table. You can move, or remove it, as needed.
Me.FacsortTableAdapter.Fill(Me.RecordDataSet.facsort)
'TODO: This line of code loads data into the 'RecordDataSet.factory' table. You can move, or remove it, as needed.
Me.FactoryTableAdapter.Fill(Me.RecordDataSet.factory)
load_id()
End Sub
Private Sub load_id()
Dim cn As New SqlConnection("Data Source=.\INSTANCE;initial catalog=record;user=sa;password=gariahat")
Dim da As New SqlDataAdapter
Dim cmd As New SqlCommand
'Dim dr As New SqlDataReader
Dim ds As New DataSet

da = New SqlDataAdapter("select * from factory", cn)
If ds.Tables.Contains("factory") Then
ds.Tables.Remove("factory")

End If
da.Fill(ds, "factory")
ComboBox1.Items.Clear()
For Each row As DataRow In ds.Tables("factory").Rows
ComboBox1.Items.Add(row(0).ToString())

Next

End Sub



Private Sub FactoryBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FactoryBindingNavigatorSaveItem.Click
Me.Validate()
Me.FactoryBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.RecordDataSet)

End Sub




Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cn As New SqlConnection("Data Source=.\INSTANCE;initial catalog=record;user=sa;password=gariahat")
Dim da As New SqlDataAdapter
Dim cmd As New SqlCommand
Dim ds As New DataSet
'Dim dr As SqlDataReader
cmd.Connection = cn
cn.Open()
cmd.CommandText = "Update facsort set " & "name = '" & TextBox1.Text & "', " & "type='" & TextBox2.Text & " '," & "shape='" & TextBox3.Text & " '," & "description='" & TextBox4.Text & " ' ," & "qty='" & TextBox5.Text & " '," & "wt_gvn = '" & TextBox6.Text & "', " & "issue_dt = '" & Format(CDate(TextBox7.Text), "MM/dd/yyyy") & "'," & "wt_rtn='" & TextBox8.Text & "'," & "return_dt='" & Format(CDate(DateTimePicker1.Value), "MM/dd/yyyy") & "'" & "Where lot_no = '" & ComboBox1.SelectedItem & "'"
cmd.ExecuteNonQuery()
MsgBox("Data successfully updated", MsgBoxStyle.Information)
' Me.FacsortTableAdapter.Insert(ComboBox1.Text, TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text, TextBox5.Text, TextBox6.Text, Format(CDate(TextBox7.Text), "dd/MM/yyyy"), TextBox8.Text, Format(CDate(DateTimePicker1.Value), "dd/MM/yyyy"))
' Me.FacsortTableAdapter.Fill(Me.RecordDataSet.facsort)
Me.TextBox8.Text = ""
Me.DateTimePicker1.Text = ""
End Sub

Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim cn As New SqlConnection("Data Source=.\INSTANCE;initial catalog=record;user=sa;password=gariahat")
Dim da As New SqlDataAdapter
Dim cmd As New SqlCommand
Dim ds As New DataSet
Dim tb2 As DataTable

Try
cmd.Connection = cn
cn.Open()
da = New SqlDataAdapter("select * from facsort", cn)
tb2 = New DataTable
da.Fill(tb2)
FacsortDataGridView.DataSource = tb2
For i As Integer = 0 To Me.FacsortDataGridView.Rows.Count - 1

Me.FacsortDataGridView.Rows(i).Cells("return_dt").Style.BackColor = Color.Red
Me.FacsortDataGridView.Rows(i).Cells("wt_rtn").Style.BackColor = Color.Red


Next
sudeshna from bangkok 16-Jul-13 0:16am    
this is my full code where it displays in gridview all the records after returned date has been entered.

1 solution

IT IS SIMPLE, YOU WRITE DOWN THE SQL SELECT QUERY CODE AND RUN IT, YOU WILL GET THE DATA YOU DESIRED. NOW DISPLAY IT IN THE DATAGRID. AS SIMPLE AS.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900