hi,i want to insert booking_no as combination of year and sno(year/sno) into database here iam giving the code as follows,,,,,,,,,
here sno started from 1.........

Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("guest1").ConnectionString())
        Dim booking_no, sno As String
 If Len(sno) = 1 Then
            sno = "0000" + CStr(sno)
        End If
        If Len(sno) = 2 Then
            sno = "000" + CStr(sno)
        End If
        If Len(sno) = 3 Then
            sno = "00" + CStr(sno)
        End If
        If Len(sno) = 4 Then
            sno = "0" + CStr(sno)
        End If
        If Len(sno) = 5 Then
            sno = "" + CStr(sno)
        End If

        booking_no = CStr(year) & "/" & sno
conn.open()
Dim insert As New SqlClient.SqlCommand("insert into guesthouse(booking_no,sno) values('" & booking_no & "' ,'" & sno & "' ", conn)
        insert.ExecuteNonQuery()
conn.close()

but here booking_no was not inserted properly,it was inserted as "0/ ",,
iwant to insert booking_no as "2010/sno" ,
,,,pls help me,urgent,,,,,,,

first of all tell me what is the starting value of sno.
U have not assign the value of sno.
what is it stand for?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.