Click here to Skip to main content
15,915,093 members

Comments by Member 13738315 (Top 18 by date)

Member 13738315 22-Apr-18 4:37am View    
I want to count the value of column. Count number of days in a column.
Member 13738315 19-Apr-18 3:03am View    
ok.. itry it... if you help me,,pls see my coding below...

Try

If Len(Trim(TextBox2.Text)) = 0 Then
MessageBox.Show("Please enter staff name", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
TextBox2.Focus()
Exit Sub
End If
If RadioButton1.Checked = False And RadioButton2.Checked = False Then
MessageBox.Show("Please select gender", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
Exit Sub
End If
If Len(Trim(TextBox3.Text)) = 0 Then
MessageBox.Show("Please enter father's name", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
TextBox3.Focus()
Exit Sub
End If
If Len(Trim(ComboBox1.Text)) = 0 Then
MessageBox.Show("Please select department", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
ComboBox1.Focus()
Exit Sub
End If
If Len(Trim(TextBox5.Text)) = 0 Then
MessageBox.Show("Please enter temporary address", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
TextBox5.Focus()
Exit Sub
End If
If Len(Trim(TextBox6.Text)) = 0 Then
MessageBox.Show("Please enter permanent address", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
TextBox6.Focus()
Exit Sub
End If
If Len(Trim(TextBox8.Text)) = 0 Then
MessageBox.Show("Please enter mobile no.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
TextBox8.Focus()
Exit Sub
End If
If RadioButton1.Checked = True Then
Gender = RadioButton1.Text
End If
If RadioButton2.Checked = True Then
Gender = RadioButton2.Text
End If
conn = New SqlConnection(Connstring)
conn.Open()


sqlstring = "insert into Staff([Staff Id], [Staff Name}, [Father Name],DateOfJoining, Department, [Temporary Address], [Permanent Address], DOB, [Phone No], [Mobile No], [Email Id], Photo,Gender) VALUES('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "',#" & DateTimePicker1.Text & "#,'" & ComboBox1.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & DateTimePicker2.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & "','" & TextBox9.Text & "',@image,'" & Gender & "'"
cmd = New SqlCommand(sqlstring, conn)

cmd.Connection = conn
Dim ms As New MemoryStream()
Dim bmpImage As New Bitmap(PictureBox1.Image)
bmpImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim data As Byte() = ms.GetBuffer()
Dim p As New SqlParameter("@image", SqlDbType.VarBinary)
p.Value = data
cmd.Parameters.Add(p)
cmd.ExecuteNonQuery()
cmd.Dispose()
conn.Close()

MessageBox.Show("Successfully saved", " Staff Record", MessageBoxButtons.OK, MessageBoxIcon.Information)
Button3.Enabled = False
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Member 13738315 15-Apr-18 3:43am View    
ok bro...thanks...what is the mean by BOM. how to delared it..
Member 13738315 15-Apr-18 3:07am View    
no, it have not prb with columns..it in rows...i think the end of the coding must have the looping statement. it can insert the first row details(Staff Id, Staff Name, Status, Date) in database..But cannot insert second and another columns of datagridview values...lets tell about this placed looping statement..pls..
Member 13738315 15-Apr-18 3:04am View    
No, i dont have prb in columns ,it is rows. Actually the datagridview first row can be added. It insert the first row( staffName, StaffId, Status, and date). But it cannot insert the 2nd and another rows details...i think end of the coding must have looping statements..lets tell about it...