Database Sqlite insert datetime - vb.net

I have a SQL Lite database and I want to insert the time in a 24 hour system.
table
error msg
Dim com As New SQLiteCommand("INSERT INTO ROSY_TB(ROSY_CODE,ROSY_DESCREPTION,ROSY_FROM,ROSY_TO,ROSY_ALLOWFR,ROSY_ALLOWTO,ROSY_APSENTA,ROSY_APSENTB,ROSY_WORKHOUR,ROSY_APSENTNUM,ROSY_CHECK) VALUES (#ROSY_CODE,#ROSY_DESCREPTION,#ROSY_FROM,#ROSY_TO,#ROSY_ALLOWFR,#ROSY_ALLOWTO,#ROSY_APSENTA,#ROSY_APSENTB,#ROSY_WORKHOUR,#ROSY_APSENTNUM,#ROSY_CHECK)", con)
com.Parameters.AddWithValue("#ROSY_CODE", DbType.String).Value = ROSYUPDATE_F.LAB_CODEVAL.Text
com.Parameters.AddWithValue("#ROSY_DESCREPTION", DbType.String).Value = ROSYUPDATE_F.TEXT_DESCREPTION.Text
com.Parameters.AddWithValue("#ROSY_FROM", DbType.DateTime).Value = Format(ROSYUPDATE_F.DATE_FROM.Value, "HH:mm tt") 'ROSYUPDATE_F.DATE_FROM.Value.ToLongTimeString
com.Parameters.AddWithValue("#ROSY_TO", DbType.DateTime).Value = Format(ROSYUPDATE_F.DATE_TO.Value, "HH:mm tt")
com.Parameters.AddWithValue("#ROSY_ALLOWFR", DbType.Int64).Value = CInt(Val(ROSYUPDATE_F.TEXT_ALLOWFR.Text))
com.Parameters.AddWithValue("#ROSY_ALLOWTO", DbType.Int64).Value = CInt(Val(ROSYUPDATE_F.TEXT_ALLOWTO.Text))
com.Parameters.AddWithValue("#ROSY_APSENTA", DbType.String).Value = ROSYUPDATE_F.COM_APSENTA.SelectedItem
com.Parameters.AddWithValue("#ROSY_APSENTB", DbType.String).Value = ROSYUPDATE_F.COM_APSENTB.SelectedItem
com.Parameters.AddWithValue("#ROSY_WORKHOUR", DbType.Int64).Value = CInt(Val(ROSYUPDATE_F.TEXT_WORKHOUR.Text))
com.Parameters.AddWithValue("#ROSY_APSENTNUM", DbType.Int64).Value = CInt(Val(ROSYUPDATE_F.COUNTSPENT))
com.Parameters.AddWithValue("#ROSY_CHECK", DbType.Boolean).Value = True
con.Open()
com.ExecuteNonQuery()
con.Close()

Related

Crystal report not showing

I created a crystal report and after running it was outputting all the details as required. am surprised now that when I run the same report now the report is showing blank fields with no data below is my code.
Try
Dim rpt As New rptCheckoutNewReceipt 'The report you created.
Dim myConnection As SqlConnection
Dim MyCommand, MyCommand1, MyCommand2, MyCommand3, MyCommand4, MyCommand5 As New SqlCommand()
Dim myDA, myDA1, myDA2, myDA3, myDA4, myDA5 As New SqlDataAdapter()
Dim myDS As New DataSet 'The DataSet you created.
Dim pdfFile As String = Application.StartupPath & "\Report.Pdf"
myConnection = New SqlConnection(cs)
MyCommand.Connection = myConnection
MyCommand1.Connection = myConnection
MyCommand2.Connection = myConnection
MyCommand3.Connection = myConnection
MyCommand4.Connection = myConnection
MyCommand5.Connection = myConnection
MyCommand.CommandText = "SELECT CheckInTime,CheckOutTime, OtherCharge, Room.R_ID, Room.RoomNo, Room.PlanCode, Room.RoomType, Room.MaxNoOfAdults, Room.MaxNoOfKids, Room.Active, CheckIN_Room.Cin_Id, CheckIN_Room.GuestID,CheckIN_Room.RoomID, CheckIN_Room.RoomCharges, CheckIN_Room.DateIN, CheckIN_Room.DateOUT, CheckIN_Room.NoOfDays, CheckIN_Room.NoOfMales, CheckIN_Room.NoOfFemales, CheckIN_Room.NoOfKids, CheckIN_Room.NoOfExtraBed, CheckIN_Room.NoOfExtraPerson, CheckIN_Room.RoomOrderCharges, CheckIN_Room.ExtraPersonCharges, CheckIN_Room.TotalRoomCharges, CheckIN_Room.ExtraBedCharges, CheckIN_Room.OtherCharges, CheckIN_Room.DiscountPer, CheckIN_Room.DiscountAmount, CheckIN_Room.STPer, CheckIN_Room.STAmount, CheckIN_Room.LuxuryTaxPer, CheckIN_Room.LuxuryTaxAmount, CheckIN_Room.SubTotal, CheckIN_Room.GrandTotal, CheckIN_Room.TotalPaid, CheckIN_Room.Balance, CheckIN_Room.Status, CheckIN_Room.Notes, Guest.ID, Guest.GuestID AS Expr2, Guest.GuestName, Guest.Address, Guest.City, Guest.Country, Guest.ContactNo, Guest.Gender, Guest.Occupation, Guest.Religion, Guest.Email, Guest.IDType, Guest.IDNumber, Guest.Pic1, Guest.Pic2, Guest.pic3, Guest.Notes AS Expr3, Guest.Company, Guest.Model, Guest.VehicleNo, Guest.Color FROM Room INNER JOIN CheckIN_Room ON Room.R_ID = CheckIN_Room.RoomID INNER JOIN Guest ON CheckIN_Room.GuestID = Guest.ID where Status='Checked Out' and Cin_ID=" & txtCheckInID.Text & ""
MyCommand1.CommandText = "SELECT * from Hotel"
MyCommand2.CommandText = "SELECT * from Currency"
MyCommand3.CommandText = "SELECT Laundry_BillInfo.Id, Laundry_BillInfo.BillNo, Laundry_BillInfo.BillDate, Laundry_BillInfo.CheckInID, Laundry_BillInfo.GrandTotal, Laundry_BillInfo.PaymentMode, Laundry_BillInfo.TotalPayment,Laundry_BillInfo.PaymentDue, Laundry_BillInfo.LB_Status, LaundryServices.LS_Id, LaundryServices.BillID, LaundryServices.Service, LaundryServices.Rate, LaundryServices.Qty, LaundryServices.TotalAmount,CheckIN_Room.Cin_Id, CheckIN_Room.GuestID, CheckIN_Room.RoomID, CheckIN_Room.RoomCharges, CheckIN_Room.DateIN, CheckIN_Room.DateOUT, CheckIN_Room.NoOfDays, CheckIN_Room.NoOfMales, CheckIN_Room.NoOfFemales, CheckIN_Room.NoOfKids, CheckIN_Room.NoOfExtraBed, CheckIN_Room.NoOfExtraPerson, CheckIN_Room.RoomOrderCharges, CheckIN_Room.ExtraPersonCharges,CheckIN_Room.TotalRoomCharges, CheckIN_Room.ExtraBedCharges, CheckIN_Room.OtherCharges, CheckIN_Room.DiscountPer, CheckIN_Room.DiscountAmount, CheckIN_Room.STPer,CheckIN_Room.STAmount, CheckIN_Room.LuxuryTaxPer, CheckIN_Room.LuxuryTaxAmount, CheckIN_Room.SubTotal, CheckIN_Room.GrandTotal AS Expr1, CheckIN_Room.TotalPaid, CheckIN_Room.Balance,CheckIN_Room.Status, CheckIN_Room.Notes FROM Laundry_BillInfo INNER JOIN LaundryServices ON Laundry_BillInfo.Id = LaundryServices.BillID INNER JOIN CheckIN_Room ON Laundry_BillInfo.CheckInID = CheckIN_Room.Cin_Id where Status='Checked Out' and Cin_ID=" & txtCheckInID.Text & " order by BillNo"
MyCommand4.CommandText = "SELECT Room_OrderInfo.Id, Room_OrderInfo.BillNo, Room_OrderInfo.BillDate, Room_OrderInfo.CheckInId, Room_OrderInfo.GrandTotal, Room_OrderInfo.PaymentMode, Room_OrderInfo.TotalPayment,Room_OrderInfo.PaymentDue, Room_OrderInfo.Operator, Room_OrderInfo.RO_Status, Room_OrderedProduct.OP_Id, Room_OrderedProduct.BillID, Room_OrderedProduct.Dish_Liquor,Room_OrderedProduct.Volumn, Room_OrderedProduct.TakenFrom, Room_OrderedProduct.VATPer, Room_OrderedProduct.VATAmount, Room_OrderedProduct.STPer, Room_OrderedProduct.STAmount, Room_OrderedProduct.DiscountPer, Room_OrderedProduct.DiscountAmount, Room_OrderedProduct.Rate, Room_OrderedProduct.Quantity, Room_OrderedProduct.Amount, Room_OrderedProduct.TotalAmount,CheckIN_Room.Cin_Id, CheckIN_Room.GuestID, CheckIN_Room.RoomID, CheckIN_Room.RoomCharges, CheckIN_Room.DateIN, CheckIN_Room.DateOUT, CheckIN_Room.NoOfDays, CheckIN_Room.NoOfMales,CheckIN_Room.NoOfFemales, CheckIN_Room.NoOfKids, CheckIN_Room.NoOfExtraBed, CheckIN_Room.NoOfExtraPerson, CheckIN_Room.RoomOrderCharges, CheckIN_Room.ExtraPersonCharges, CheckIN_Room.TotalRoomCharges, CheckIN_Room.ExtraBedCharges, CheckIN_Room.OtherCharges, CheckIN_Room.DiscountPer AS Expr1, CheckIN_Room.DiscountAmount AS Expr2, CheckIN_Room.STPer AS Expr3, CheckIN_Room.STAmount AS Expr4, CheckIN_Room.LuxuryTaxPer, CheckIN_Room.LuxuryTaxAmount, CheckIN_Room.SubTotal, CheckIN_Room.GrandTotal AS Expr5, CheckIN_Room.TotalPaid, CheckIN_Room.Balance, CheckIN_Room.Status, CheckIN_Room.Notes FROM Room_OrderInfo INNER JOIN Room_OrderedProduct ON Room_OrderInfo.Id = Room_OrderedProduct.BillID INNER JOIN CheckIN_Room ON Room_OrderInfo.CheckInId = CheckIN_Room.Cin_Id where Status='Checked Out' and Cin_ID=" & txtCheckInID.Text & " order by BillNo"
MyCommand5.CommandText = "SELECT * from Checkin_Payment where CheckInID =" & txtCheckInID.Text & ""
MyCommand.CommandType = CommandType.Text
MyCommand1.CommandType = CommandType.Text
MyCommand2.CommandType = CommandType.Text
MyCommand3.CommandType = CommandType.Text
MyCommand4.CommandType = CommandType.Text
MyCommand5.CommandType = CommandType.Text
myDA.SelectCommand = MyCommand
myDA1.SelectCommand = MyCommand1
myDA2.SelectCommand = MyCommand2
myDA3.SelectCommand = MyCommand3
myDA4.SelectCommand = MyCommand4
myDA5.SelectCommand = MyCommand5
myDA.Fill(myDS, "Guest")
myDA.Fill(myDS, "Room")
myDA.Fill(myDS, "CheckIn_Room")
myDA1.Fill(myDS, "Hotel")
myDA2.Fill(myDS, "Currency")
myDA3.Fill(myDS, "Laundry_BillInfo")
myDA3.Fill(myDS, "LaundryServices")
myDA4.Fill(myDS, "Room_OrderInfo")
myDA4.Fill(myDS, "Room_OrderedProduct")
myDA5.Fill(myDS, "Checkin_Payment")
rpt.SetDataSource(myDS)
rpt.Subreports(0).SetDataSource(myDS)
rpt.Subreports(1).SetDataSource(myDS)
rpt.SetParameterValue("v1", txtBillNo.Text)
rpt.SetParameterValue("v2", dtpBillDate.Value)
frmReport.CrystalReportViewer1.ReportSource = rpt
frmReport.ShowDialog()

Drop down list display 0

strsql = "Select Sup_Name + '-----' + Sup_Code As Supdisplay , Sup_Code From kjm_supplier_profile Order By Sup_Name "
cmd = New MySqlCommand(strsql, Conn)
rdr = cmd.ExecuteReader
strddl.DataSource = rdr
strddl.DataTextField = "Supdisplay"
strddl.DataValueField = "Sup_Code"
strddl.DataBind()
strddl.Items.Insert(0, New ListItem("Please Select Supplier", ""))
rdr.Close()
This is to bind the data to the drop-down list with two data. But the drop-down list display 0
strsql = "Select Sup_Name + '-----' + Sup_Code As Supdisplay , Sup_Code From kjm_supplier_profile Order By Sup_Name "
cmd = New MySqlCommand(strsql, Conn)
rdr = cmd.ExecuteReader
strddl.DataSource = rdr
strddl.DataTextField = "Sup_Name "
strddl.DataValueField = "Supdisplay "
strddl.DataBind()
strddl.Items.Insert(0, New ListItem("Please Select Supplier", ""))
rdr.Close()

oledb update query error

I'm updating my MS Access db via VB code:
Private Sub btnUpdate_Click(sender As Object, e As EventArgs) Handles btnUpdate.Click
Dim query As String = "UPDATE Employee SET EmpName = #EmpName , MobNo = #MobNo , Email_ID = #Email , EmpAdd = #EmpAdd , FatName = #FatName , Sex = #Sex , Pan = #Pan , AccNo = #AccNo , BankName = #BankName , MICR = #MICR , BasicPay = #BasicPay , passwd = #passwd , DOB = #DOB WHERE id = #id "
Try
Call OpenConn()
Dim cmd As New OleDbCommand(query, conn)
cmd.Parameters.Add("#MobNo", OleDbType.VarWChar, 13, "MobNo").Value = txtMobNo.Text
cmd.Parameters.Add("#Email", OleDbType.VarWChar, 50, "Email_ID").Value = txtEmail.Text
cmd.Parameters.Add("#EmpName", OleDbType.VarWChar, 255, "EmpName").Value = txtName.Text
cmd.Parameters.Add("#DOB", OleDbType.VarWChar, 10, "DOB").Value = txtDOB.Value
cmd.Parameters.Add("#EmpAdd", OleDbType.VarWChar, 255, "EmpAdd").Value = txtAddress.Text
cmd.Parameters.Add("#FatName", OleDbType.VarWChar, 255, "FatName").Value = txtFatName.Text
cmd.Parameters.Add("#Sex", OleDbType.VarWChar, 6, "Sex").Value = cboSex.Text
cmd.Parameters.Add("#Nationality", OleDbType.VarWChar, 30, "Nationality").Value = txtNationality.Text
cmd.Parameters.Add("#Pan", OleDbType.VarWChar, 20, "Pan").Value = txtPan.Text
cmd.Parameters.Add("#AccNo", OleDbType.VarWChar, 20, "AccNo").Value = txtAccNo.Text
cmd.Parameters.Add("#BankName", OleDbType.VarWChar, 50, "BankName").Value = txtBankName.Text
cmd.Parameters.Add("#MICR", OleDbType.VarWChar, 20, "MICR").Value = txtMICR.Text
cmd.Parameters.Add("#DedRate", OleDbType.VarWChar, 3, "DedRate").Value = txtDedRate.Text
cmd.Parameters.Add("#BasicPay", OleDbType.VarWChar, 10, "BasicPay").Value = txtBasicPay.Text
'cmd.Parameters.AddWithValue("#CL", Convert.ToInt64(txtNoOfCl.Text))
'cmd.Parameters.AddWithValue("#ML", Convert.ToInt64(txtNoOfMl.Text))
cmd.Parameters.Add("#passwd", OleDbType.VarWChar, 20, "passwd").Value = txtPasswd.Text
cmd.Parameters.Add("#id", OleDbType.BigInt, 3, "id").Value = Val(txtId.Text)
cmd.Prepare()
cmd.ExecuteNonQuery()
Call CloseConn()
MsgBox("Data Updated Successfully", vbInformation, "Update")
DisableTxt(Me)
btnUpdate.Visible = False
btnEdit.Enabled = False
btnEdit.Visible = False
ClearTxt(Me)
Catch ex As Exception
MsgBox("Fatal error occured :" & vbNewLine & "source : " & vbNewLine & ex.Source & vbNewLine & "messege :" & vbNewLine & ex.ToString)
End Try
End Sub
But update is not working. Any ideas?
With OleDB you can't use named parameters. You have to use ? as a placeholder and the order of the parameters is significant.
See here: http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbcommand.parameters(v=vs.110).aspx

updating database that accepts null values on date and time textbox

i updated my code i added .Value = DBNull.Value in the lines
any suggestions regarding updating database that accepts null values on date and time textbox any recommendations/suggestions are highly appreciated
Dim cmd As SqlCommand = sqlconn.CreateCommand
sqlconn.Open()
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "UpdateEquipmentProfile"
'declare the variables'
cmd.Parameters.Add("#OE_ID", SqlDbType.VarChar, 11, "oeq-su-999").Value = DBNull.Value
cmd.Parameters.Add("#OE_Category", SqlDbType.Char, 3, "COM").Value = DBNull.Value
cmd.Parameters.Add("#OE_SubCategory", SqlDbType.Char, 3, "SU").Value = DBNull.Value
cmd.Parameters.Add("#OE_Name", SqlDbType.VarChar, 35, "adminpmis01").Value = DBNull.Value
cmd.Parameters.Add("#OE_User", SqlDbType.VarChar, 35, "Ivan").Value = DBNull.Value
cmd.Parameters.Add("#OE_Brand", SqlDbType.VarChar, 15, "DELL").Value = DBNull.Value
cmd.Parameters.Add("#OE_Model", SqlDbType.VarChar, 35, "optiplex").Value = DBNull.Value
cmd.Parameters.Add("#OE_Specs", SqlDbType.VarChar, 1000, "dualcore").Value = DBNull.Value
cmd.Parameters.Add("#OE_SerialNo", SqlDbType.VarChar, 35, "sgh5960").Value = DBNull.Value
cmd.Parameters.Add("#OE_PropertyNo", SqlDbType.VarChar, 35, "j7h7h6g6f2").Value = DBNull.Value
cmd.Parameters.Add("#OE_MacAddress", SqlDbType.VarChar, 100, "j7h7:h6g6f2").Value = DBNull.Value
cmd.Parameters.Add("#OE_Static_IP", SqlDbType.VarChar, 15, "192.168.1.5").Value = DBNull.Value
cmd.Parameters.Add("#OE_Vendor", SqlDbType.VarChar, 35, "ADWAYS").Value = DBNull.Value
cmd.Parameters.Add("#OE_PurchaseDate", SqlDbType.SmallDateTime).Value = DBNull.Value
cmd.Parameters.Add("#OE_WarrantyInclusiveYear", SqlDbType.Int).Value = DBNull.Value
cmd.Parameters.Add("#OE_WarrantyStatus", SqlDbType.Char, 2, "IN").Value = DBNull.Value
cmd.Parameters.Add("#OE_Status", SqlDbType.VarChar, 15, "Good").Value = DBNull.Value
cmd.Parameters.Add("#OE_Dept_Code", SqlDbType.Char, 3, "ADM").Value = DBNull.Value
cmd.Parameters.Add("#OE_Location_Code", SqlDbType.Char, 8, "ADM_OFC").Value = DBNull.Value
cmd.Parameters.Add("#OE_Remarks", SqlDbType.VarChar, 1000, "ACTIVE").Value = DBNull.Value
cmd.Parameters("#OE_ID").Value = txtOEID.Text
cmd.Parameters("#OE_Category").Value = cmbCategory.Text
cmd.Parameters("#OE_SubCategory").Value = cmbSubCategory.Text
cmd.Parameters("#OE_Name").Value = txtName.Text
cmd.Parameters("#OE_User").Value = txtUser.Text
cmd.Parameters("#OE_Brand").Value = cmbBrand.Text
cmd.Parameters("#OE_Model").Value = cmbModel.Text
cmd.Parameters("#OE_Specs").Value = txtSpecs.Text
cmd.Parameters("#OE_SerialNo").Value = txtSerialNo.Text
cmd.Parameters("#OE_PropertyNo").Value = txtPropertyNo.Text
cmd.Parameters("#OE_MacAddress").Value = txtMacAddress.Text
cmd.Parameters("#OE_Static_IP").Value = txtStaticIp.Text
cmd.Parameters("#OE_Vendor").Value = txtVendor.Text
cmd.Parameters("#OE_PurchaseDate").Value = txtPurchaseDate.Text
cmd.Parameters("#OE_WarrantyInclusiveYear").Value = txtWarrantyInclusiveYear.Text
cmd.Parameters("#OE_WarrantyStatus").Value = txtWarrantyStatus.Text
cmd.Parameters("#OE_Status").Value = txtStatus.Text
cmd.Parameters("#OE_Dept_Code").Value = cmbDeptCode.Text
cmd.Parameters("#OE_Location_Code").Value = cmbLocationCode.Text
cmd.Parameters("#OE_Remarks").Value = txtRemarks.Text
cmd.ExecuteNonQuery()
MsgBox("Successfully Updated Equipment Profile")
sqlconn.Close()
1.First of all if you have not set that DateTime field's allow null property,set it to allow null,so that it accepts null.
2.Then in your UI code dont pass the parameter if Date is not entered in Textbox.
3.Then in your code for passing parameter value check if the parameter value is null the pass that parameter's value as as DBNull.Value.

"false" text being inserted into my database

I have an insert statement with a number of DataGridViewComboBoxColumns. When I try and insert the values of these DataGridViewComboBoxColumns into my database the text "False" is being inserted into the fields.
Why is this happening?
Dim para As New SqlClient.SqlParameter
Dim dateValue As String = CStr(DateTimePicker1.Value)
Dim calendar = Microsoft.VisualBasic.Left(dateValue, 10)
para.ParameterName = "#company"
para.Value = company.Selected.ToString
para.ParameterName = "#division"
para.Value = division.Selected.ToString
para.ParameterName = "#date"
para.Value = DateTimePicker1.Value
para.ParameterName = "#supplier"
para.Value = supplier.Selected.ToString
para.ParameterName = "#material_group"
para.Value = materialGroup.Selected.ToString
para.ParameterName = "#cost"
para.Value = netprice.Selected.ToString
para.ParameterName = "#dsc"
para.Value = description.Selected.ToString
para.ParameterName = "#email"
para.Value = cmbEmail.SelectedValue
para.ParameterName = "#userID"
para.Value = id
para.ParameterName = "#Name"
para.Value = txtEmployee.Text
para.ParameterName = "#val"
para.Value = newName
para.ParameterName = "#quantity"
para.Value = quantity.Selected.ToString
para.ParameterName = "#wbs"
para.Value = wba.Selected.ToString
para.ParameterName = "#marketingCode"
para.Value = markCodes.Selected.ToString
para.ParameterName = "#hccNumber"
para.Value = hccNumber.Selected.ToString
para.ParameterName = "#currency"
para.Value = currency.Selected.ToString
Insert details:
Dim con As New SqlClient.SqlConnection
Dim myCommand As New SqlClient.SqlCommand
myCommand.Parameters.Add("#company", SqlDbType.NVarChar, 30).Value = company.Selected.ToString
myCommand.Parameters.Add("#division", SqlDbType.NVarChar, 30).Value = division.Selected.ToString
myCommand.Parameters.Add("#date", SqlDbType.NVarChar, 30).Value = DateTimePicker1.Value
myCommand.Parameters.Add("#supplier", SqlDbType.NVarChar, 30).Value = supplier.Selected.ToString
myCommand.Parameters.Add("#material_group", SqlDbType.NVarChar, 30).Value = materialGroup.Selected.ToString
myCommand.Parameters.Add("#cost", SqlDbType.NVarChar, 30).Value = netprice.Selected.ToString
myCommand.Parameters.Add("#dsc", SqlDbType.NVarChar, 30).Value = description.Selected.ToString
myCommand.Parameters.Add("#email", SqlDbType.NVarChar, 30).Value = cmbEmail.SelectedValue
myCommand.Parameters.Add("#userID", SqlDbType.NVarChar, 30).Value = id
myCommand.Parameters.Add("#Name", SqlDbType.NVarChar, 30).Value = newName
myCommand.Parameters.Add("#quantity", SqlDbType.NVarChar, 40).Value = quantity.Selected.ToString
myCommand.Parameters.Add("#wbs", SqlDbType.NVarChar, 40).Value = wba.Selected.ToString
myCommand.Parameters.Add("#marketingCode", SqlDbType.NVarChar, 40).Value = markCodes.Selected.ToString
myCommand.Parameters.Add("#hccNumer", SqlDbType.NVarChar, 40).Value = hccNumber.ToString
myCommand.Parameters.Add("#currency", SqlDbType.NVarChar, 40).Value = currency.Selected.ToString
Dim myAdapter As New SqlClient.SqlDataAdapter
Dim sql As String = "Insert into details (company, division, date, supplier, material_group, cost, dsc, email, userID, fullName, marketingCode, wbs, qty, currency) VALUES (#company, #division, #date, #supplier, #material_group, #cost, #dsc, #email, #userID, #Name, #marketingCode, #wbs, #quantity, #currency)"
myCommand.Connection = con
myCommand.CommandText = sql
myAdapter.InsertCommand = myCommand
myCommand.Connection.Open()
myCommand.ExecuteNonQuery()
myCommand.Connection.Close()
You are storing if something is selected.
para.Value = company.Selected.ToString
Selected is a boolean!
I'm not certain on what you are trying to achieve here, but I don't think this script will work how you wish. You're not building a list of parameters with values, but replacing one parameter object over and over.
para.ParameterName = "#company"
para.Value = company.Selected.ToString
para.ParameterName = "#division"
para.Value = division.Selected.ToString
This will just first set the para object to be #company, and value: company.Selected.ToString, then set it again to be #division and value: division.Selected.ToString.
Your datatypes are all NVarChar and you are explicitly setting your boolean values to a string (.ToString()).
If you wish to store boolean values, change your data types to bit. Then change your values so you are passing the boolean value, not an explicitly converted boolean to string:
myCommand.Parameters.Add("#currency", SqlDbType.bit).Value = currency.Selected
company.selected returns true if the item is selected, and false if not...
You probably want to use company.ToString