poojavb 29 Junior Poster

IsDigit code will allow to enter everything apart from digits....

  'accepts only alphabets
          If (Microsoft.VisualBasic.Asc(e.KeyChar) < 65) Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 90) _
          And (Microsoft.VisualBasic.Asc(e.KeyChar) < 97) Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 122) Then
               e.Handled = True
          End If
          If (Microsoft.VisualBasic.Asc(e.KeyChar) = 8) Then
               e.Handled = False
          End If
Reverend Jim commented: unnecessarily complicated and has redundant code +0
poojavb 29 Junior Poster
 Private Sub TextBox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
     'accepts only numbers
     If (Microsoft.VisualBasic.Asc(e.KeyChar) < 48) Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 57) Then
         e.Handled = True
     End If
     If (Microsoft.VisualBasic.Asc(e.KeyChar) = 8) Then
         e.Handled = False
     End If
 End Sub
Reverend Jim commented: does the opposite of what was asked -2
poojavb 29 Junior Poster

U need this code / idea in which programming laguage???

poojavb 29 Junior Poster

For deleting data with the help of datagridview and updating in access u can use

'Open connection
   Dim i As Integer
    Dim ID As String
    i = DatagridView1.CurrentRow.Index
    ID = DatagridView1.Item(0, i).Value 'whichever will be primarykey or unique data
      Try
        Dim MessageText As String
        Dim myCommand As OleDbCommand
        myCommand = New OleDbCommand("Delete from tablename where colname='" + ID + "'", Connection)
        Dim DBReader As OleDbDataReader = myCommand.ExecuteReader
        DBReader.Close()
      Catch ex As Exception
        MsgBox("Error in delete query: " + ex.Message)
      End Try
'then show the updated datagridview again

Hope this helps

poojavb 29 Junior Poster

Hello Friends,

I need help to get the time value from MSSQL database to VB.Net Datetimepicker

I have a datetimepicker but the custom format is set to HH:mm tt so that I can get eg 11:20 AM

this value I have stored in database with the help of Label4.Text = DateTimePicker3.Value.ToShortTimeString

but now if I want to get the same value from database to datetimepicker what shud be done???

please do help me on this

Thanks in advance

poojavb 29 Junior Poster

I have done the same thing for username and password...check if it works for u

Why do u write the Item(1) code cant it be just written with reader name and quote brackets column name?
reader("DrName")

if ur case sensitivity code is creating error then check below

     Try
                    Dim myCommand As OleDbCommand
                    myCommand = New OleDbCommand("SELECT * FROM userlogin where UserName='" & txtUsername.Text & "' and Password='" + txtPassword.Text + "'", Connection)
                    Dim reader As OleDbDataReader = myCommand.ExecuteReader
                    If reader.Read = True Then
                        If String.Compare(txtUsername.Text, reader("UserName"), False) Or String.Compare(txtPassword.Text, reader("Password"), False) Then
                            MsgBox("Incorrect Credentials")
                            txtPassword.Text = ""
                            txtUsername.Text = ""
                            txtUsername.Focus()
                            ErrorProvider1.Clear()
                        Else
                            frmMain.lblWelcome.Text = "Welcome, " + reader("DrName")
                            frmMain.Show()
                            Me.Close()
                        End If
                    Else
                        MsgBox("Login Failed. Try Again")
                        txtPassword.Text = ""
                        txtUsername.Text = ""
                        txtUsername.Focus()
                        ErrorProvider1.Clear()
                    End If
                        reader.Close()
                Catch ex As Exception
                    MsgBox("Error Connecting to Database: " & ex.Message)
                End Try
poojavb 29 Junior Poster
Dim di As New IO.DirectoryInfo("Your directory path")
                    Debug.Print("di: " + di.ToString)
                    Dim diar1 As IO.FileInfo() = di.GetFiles()
                    Dim dra As IO.FileInfo
                    'list the names of all files in the specified directory
                    For Each dra In diar1
                        lstFiles.Items.Add(dra) 'all files present in the directory are viewed in list box
                    Next

hope it helps u...

Jx_Man commented: VB.Net solution for VB6 ? -3
poojavb 29 Junior Poster

example iam the employee and i want to have a vacation leave and i want to have a vacation in 4 days and the vacation leave have 10 days maximum so if i get 4 days my vacation leave will be 6 days automatically

then on my another vacation i want to used again my vacation leave and i want to acquired 3 days so my vacation leave will be 3 days left automatically

here`s my problem sir...i cant get the total value of my first transaction to my available days
example 10 is the available and i used 3 so my left days is 7
on my another transaction the available days was 10 again which is wrong
10 - 3 = 7 first transaction
7 - 2 = 5 second transaction

please help me T_T

Try this

select  DateDiff("d",(Format([FromDate], 'MM/dd/yyyy')),(Format([ToDate], 'MM/dd/yyyy'))) from Tablename
poojavb 29 Junior Poster

Hey guys!

I need a little help with Crystal Reports!The Report keeps repeating the details.I tried to group it by the reference number but it keeps displaying it four times!Also how can I order the report by reference number?Please help me its the last thing for me to finish my software!Here's my code:

Dim crptdoc As New CrystalReport1
        Dim mystr As String
        Dim myDS As New DataSet1

        crptdoc.Load("C:\Users\ACP\Documents\Visual Studio 2005\Projects\Sistema ManoObras\SistemaManoObras\SistemaManoObras")
        crptdoc.SetDataSource(myDS.Tables("Payroll"))

        mystr = "{Employees.EmployeeID} = " & Val(Form1.TxtEmpID.Text) & "and {Payroll.PayrollID} = " & Val(Form1.TxtPayrollID.Text) & ""
       
 CrystalReportViewer1.SelectionFormula = mystr
        CrystalReportViewer1.ReportSource = crptdoc

[icode]
[/QUOTE] 

Try out this


[code]

[code]

'Import
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

'Form Load event
      Dim cryRpt As New ReportDocument
        cryRpt.Load(Application.StartupPath & "\Reports\CRBill.rpt")'ur crystal report path goes here

        Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        Dim crParameterFieldDefinition As ParameterFieldDefinition
        Dim crParameterValues As New ParameterValues
        Dim crParameterDiscreteValue As New ParameterDiscreteValue

        crParameterDiscreteValue.Value = frmMain.dtpFromBill.Value.ToString("yyyy-MM-dd")
        crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
        crParameterFieldDefinition = crParameterFieldDefinitions.Item("fromdate") 'the red one is the paramenter name I have created
        crParameterValues = crParameterFieldDefinition.CurrentValues

        crParameterValues.Clear()
        crParameterValues.Add(crParameterDiscreteValue)
        crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)


        crParameterDiscreteValue.Value = frmMain.dtpToBill.Value.ToString("yyyy-MM-dd")
        crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
        crParameterFieldDefinition = crParameterFieldDefinitions.Item("todate")'the red one is the paramenter name I have created

        crParameterValues = crParameterFieldDefinition.CurrentValues

        crParameterValues.Add(crParameterDiscreteValue)
        crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)

        crParameterDiscreteValue.Value = frmMain.txtPatName.Text
        crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
        crParameterFieldDefinition = crParameterFieldDefinitions.Item("patname")'the red one is the paramenter name I have created

        crParameterValues = crParameterFieldDefinition.CurrentValues

        crParameterValues.Add(crParameterDiscreteValue)
        crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)

        crvBill.ReportSource = cryRpt
        crvBill.Refresh()

[/code]
u can set the selection formula in the crystal report itself....

First create the parameters that u need and then right click on the cystal report for report-> selection formula->record

mention the criteria in …

M.Waqas Aslam commented: unnecessary code,with out knowing the prob. -1
poojavb 29 Junior Poster

Amazing....

[Container] fixed the problem ---- THANKS!!

Just want to make sure I understand what you are saying... Container is a reserved word that can be used in SQL "UPDATE" statement?

U have missed the "+" sign in ur update query
Try this...

Try
                    Dim MessageText As String
                    Dim myCommand As OleDbCommand
                    myCommand = New OleDbCommand("UPDATE MaxTime SET Container = '"+txtMaxContainerTime.Text+"', Vehicle = '"+ txtMaxVehicleTime.Text+ "', Exterior = '"+ txtMaxExteriorTime.Text+ "', Interior = '"+txtMaxInteriorTime.Text+ "'", dbConnection)
                    myCommand.ExecuteNonQuery()
                    MessageText = "Information Updated Successfully !! "
                    MsgBox(MessageText)
                Catch ex As Exception
                    MsgBox(ex.Message)
                End Try
kingsonprisonic commented: Read the post carefully then argue. You are confusing the OP.... -1
poojavb 29 Junior Poster

Yes...

DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy - HH:mm:ss");

But how do I include the miliseconds (and the localized version of the day of the week)?

Check this

Dim MyTime As String
MyTime = DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss.fff")

It gives the output:
09-Feb-2012 18:08:14.403

Sorry its in vb.net