-1

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,,,,,,,

Edited by kanuri1: n/a

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Pari13
0

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?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.