Combobox by any contain - filter

i am trying to filter combobox by any contain but it not happening
Private Sub cboServicename()
Try
Dim myConnToAccess As OleDb.OleDbConnection = MyDBmodule()
myConnToAccess.Open()
Dim ds = New DataSet
Dim tables = ds.Tables
Dim da = New OleDb.OleDbDataAdapter("SELECT Distinct service_name from Services_Data ", myConnToAccess)
da.Fill(ds, "Services_Data")
Dim view1 As New DataView(tables(0))
With auditmodule_Servicename
.DataSource = ds.Tables("Services_Data")
.DisplayMember = "service_name"
.ValueMember = "service_code"
.SelectedIndex = 0
End With
Catch ex As Exception
End Try
End Sub

Related

Need help fixing Exception Unhandled

I am getting the following error:
System.ArgumentOutOfRangeException: 'Index and length must refer to a location within the string.
Parameter name: length'
(Look for Bold Italic on code *** that's where it is taking me to fix that)
Not sure what the problem is. Here is the whole code:
Imports GroceryApp.GroceryItem
Imports System.IO
Public Class GroceryItemForm
Private strFileName As String = String.Empty
Private Sub btnAddToBasket_Click(sender As Object, e As EventArgs) Handles btnAddToBasket.Click, AddToolStripMenuItem.Click
Dim gi As GroceryItem
Dim price As Double
' Validate that brand name is entered
If txtBrandName.Text = "" Then
MsgBox("Please input an Brand Name", , "Value Required")
txtBrandName.Focus()
Exit Sub
End If
' Validate that price is entered
If Not Double.TryParse(numPrice.Text, price) Then
MsgBox("Please input an Price", , "Value Required")
numPrice.Focus()
Exit Sub
End If
' Validate that Aisle is selected
If cboAisle.Text = "" Then
MsgBox("Please select an Aisle", , "Value Required")
cboAisle.Focus()
Exit Sub
End If
***txtScanNumber.Text = txtBrandName.Text.Substring(0, 3) & "1019"***
gi = New GroceryItem(txtScanNumber.Text, txtBrandName.Text, price)
gi.Type = [Enum].Parse(GetType(Aisle), cboAisle.Text)
gi.Description = txtDescription.Text
basket.Add(gi)
End Sub
Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click
Application.Exit()
End Sub
Private Sub ViewToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ViewToolStripMenuItem.Click
'Dim result As String = ""
'Dim i As Integer = 1
'For Each gi As GroceryItem In basket
'result = result & "Item " & i & vbNewLine & "Aisle: " & gi.Type.ToString & vbNewLine & "Scan Number: " & gi.ScanNumber & vbNewLine & "Brand Name: " & gi.BrandName & vbNewLine & vbNewLine
'i = i + 1
'Next
'MsgBox(result, , "Basket Details")
Dim oForm As BasketDisplayForm
oForm = New BasketDisplayForm()
oForm.Show()
oForm = Nothing
End Sub
Private Sub GroceryItemForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim oForm As LoginForm
oForm = New LoginForm()
oForm.Show()
oForm = Nothing
End Sub
Private Sub SaveToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SaveToolStripMenuItem.Click
Dim rowLine As String = ""
'If strFileName = String.Empty Then
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
strFileName = SaveFileDialog1.FileName
Dim fsStream As New FileStream(strFileName, FileMode.Append, FileAccess.Write)
Dim sw As New StreamWriter(fsStream)
Dim sb As New System.Text.StringBuilder
For Each Item As GroceryItem In basket
sb.AppendLine(String.Concat(Item.ScanNumber, ",", Item.Type.ToString, ",", Item.BrandName, ",", Item.Description, ",", Item.Price))
'rowLine = rowLine + Item.ScanNumber + "," + Item.Type.ToString + "," + Item.BrandName + "," + Item.Description + "," + Item.Price.ToString
Next
'IO.File.WriteAllText(strFileName, sb.ToString)
'rowLine = rowLine.Remove(rowLine.Length - 1, 1)
sw.WriteLine(sb)
sw.Flush()
MsgBox("Data Saved Successfully")
sw.Close()
basket.Clear()
End If
'End If
End Sub
Private Sub LoadToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LoadToolStripMenuItem.Click
Dim basketFile As StreamReader
Dim gi As GroceryItem
Dim sNo, brand, desc, aisle As String
Dim price As Double
Dim y As Integer
basket.Clear()
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
strFileName = OpenFileDialog1.FileName
basketFile = File.OpenText(strFileName)
' Read Power rating from file
Using sr As StreamReader = New StreamReader(strFileName)
Do While sr.Peek() > -1
For Each c As String In sr.ReadToEnd().Split(CType(Chr(10), Char))
sNo = ""
For Each d As String In c.Split(",")
If y = 0 Then
sNo = d
End If
If y = 1 Then
aisle = d
End If
If y = 2 Then
brand = d
End If
If y = 3 Then
desc = d
End If
If y = 4 Then
price = d
End If
y += 1
Next
If (sNo <> "") Then
gi = New GroceryItem(sNo, brand, price)
gi.Type = [Enum].Parse(GetType(Aisle), aisle)
gi.Description = desc
If (sNo <> "" & vbCr & "") Then
basket.Add(gi)
End If
End If
y = 0
Next
Loop
End Using
basketFile.Close()
End If
End Sub
End Class

system.rank, system.keywords from SystemIndex

Looking to fetch some nice results working with Microsoft Search.
Got some problems...
First system.rank returns allways 1000.
I tried system.HitCount, it returns allways 65535.
Then I'm trying to match a word in the Keywords using System.Keywords...
The results of the request looks allways empty on Keywords?
strQuery = "SELECT SYSTEM.FILENAME, System.Keywords FROM SYSTEMINDEX WHERE scope= '" & scope & "' AND SYSTEM.FILENAME NOT LIKE '%.tmp' AND SYSTEM.FILENAME NOT LIKE '~$%' "
Dim constring As String = "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';"
Using con As New OleDbConnection(constring)
con.Open()
Dim da As New OleDbDataAdapter(strQuery, con)
Dim table AS new DataTable()
Dim ds As New DataSet()
Dim dc AS New DataColumn()
Dim cmdSearch As New System.Data.OleDb.OleDbCommand(strQuery, con)
Dim reader As OleDbDataReader = cmdSearch.ExecuteReader()
Dim result As New ArrayList()
table.Columns.Add("filename")
table.Columns.Add("DocKeywords")
If reader.HasRows Then
Do While reader.Read()
Dim row As Datarow = table.NewRow()
row("filename") = reader.Item("system.filename")
row("DocKeywords") = reader.Item("System.Keywords") 'String.Join(",", reader.Item("System.Keywords")) 'system.string[]: empty
table.Rows.Add(row)
Loop
End If
DataGrid1.DataSource = table
DataGrid1.DataBind()

Wont insert data to Access Database, keep stuck on Open Connection

I create a Learning Aplication for English kindergarten, and I got stuck on the editing form for insert data about sing a song...
Here's my program view:
Editing Learning
Translate
Tambah = Add
Ubah = Edit
Simpan = Save
Batal = Cancel
Hapus = Delete
Cari = Find
Now the problem is, when i click SIMPAN (SAVE), nothing happened, i try click SAVE again, show up an error like this
The Connection wasn't closed
Here's the coding:
Public Class frmeditlearning
Dim baru, valid As String
Dim id1, judul1, video1, databaru As String
Dim cmd1 As New OleDbCommand(databaru, mycon)
Private Sub btntambahsing_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntambahsing.Click
'This is button for ADD when get clicked
txtjudul.Enabled = True
txtvideo.Enabled = True
txtid.Clear()
txtid.Select()
btnsingcarivideo.Enabled = True
btnsimpansing.Enabled = True
btnbatalsing.Enabled = True
btnubahsing.Enabled = False
btnhapussing.Enabled = False
baru = True
btntambahsing.Enabled = False
End Sub
Private Sub btnsimpansing_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpansing.Click
If txtid.Text = "" Or txtjudul.Text = "" Or txtvideo.Text = "" Then
MessageBox.Show("Empty textbox is not allowed!", "EMPTY TEXTBOX", MessageBoxButtons.OK, MessageBoxIcon.Information)
Return
End If
If baru = True Then
mycon.Open()
Dim noid, str As String
str = "Select id from sing where (id = '" & txtid.Text & "')"
Dim cmd As OleDbCommand = New OleDbCommand(str, mycon)
dr = cmd.ExecuteReader
While dr.Read
noid = dr("id").ToString
If txtid.Text = noid Then
mycon.Close()
MessageBox.Show("SAME ID CANNOT USED!", "DUPLICATE ID", MessageBoxButtons.OK, MessageBoxIcon.Information)
Return
Else
If Not (txtid.Text = noid) Then
mycon.Open()
id1 = txtid.Text
judul1 = txtjudul.Text
video1 = txtvideo.Text
databaru = "INSERT INTO sing (id,judul,video) values(#id,#judul,#video)"
cmd1.Parameters.AddWithValue("#id", id1)
cmd1.Parameters.AddWithValue("#judul", judul1)
cmd1.Parameters.AddWithValue("#video", video1)
cmd1.ExecuteNonQuery()
mycon.Close()
btnbatalsing.PerformClick()
End If
End If
End While
End If
End Sub
Thanks in advance, sorry if my English is bad.

Argument not specified for parameter 'e' of 'Protected Sub TextBox1(sender As Object, e As System.EventArgs)'

Imports System.Data.OleDb
Imports System.Data
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub TextBox1(sender As Object, e As System.EventArgs) Handles TextBox1.TextChanged
Dim userid As String = TextBox1.Text
Dim params(1) As OleDbParameter
params(0) = New OleDbParameter("uid", TextBox1.Text)
params(1) = New OleDbParameter("up", TextBox2.Text)
Dim sql = "select * from user where userid=#uid and userpassword=#up"
Dim ds As DataSet = AccessHelper.ExecuteDataSet(sql, params)
If ds.Tables(0).Rows.Count = 1 Then
Session("userid") = TextBox1.Text
Else
Dim paramst(1) As OleDbParameter
paramst(0) = New OleDbParameter("tid", TextBox1.Text)
paramst(1) = New OleDbParameter("tp", TextBox2.Text)
Dim sqlt = "select * from teacher where teacherid=#tid and userpassword=#tp"
Dim dst As DataSet = AccessHelper.ExecuteDataSet(sqlt, paramst)
If dst.Tables(0).Rows.Count = 1 Then
Session("teacherid") = TextBox1.Text
End If
End If
End Sub
End Class
Can't really figure out why I get the errors (http://i.imgur.com/Zb2hBlo.png)
No idea what I'm doing really but it's a check to see if the login exists. Beforehand it was saying that textbox1/2 wasn't declared but now it's switched to this; either way it doesn't work and I don't know what to do.

Using ItextSharp I am getting Unbalanced begin/end text operators. But they are Matched

I working on a app that uses ItextSharp to generate PDF files for students to print name tags and parking permits... However it keeps throwing: Unbalanced begin/end text operators. at the doc.close()
The blocks appear to be properly openned and closed.. Below is the function:
Function ID_and_Parking(ByVal id As Integer) As ActionResult
Dim _reg_info As reg_info = db.reg_info.Single(Function(r) r.id = id)
Dim _conf_info As conf_info = db.conf_info.Single(Function(f) f.id = 0)
Dim _LastName As String = _reg_info.last_name
Dim _Employer As String = _reg_info.business_name
Dim _Class_1 As String = _reg_info.tues_class
Dim _Class_2 As String = _reg_info.wed_class
Dim _Class_3 As String = _reg_info.thur_class
Dim _Class_4 As String = _reg_info.fri_class
Dim _BeginDate As String = _conf_info.conf_start_date
Dim _endDate As String = _conf_info.conf_end_date
If IsDBNull(_reg_info.tues_class) Then
_Class_1 = ""
End If
If IsDBNull(_reg_info.wed_class) Then
_Class_2 = ""
End If
If IsDBNull(_reg_info.thur_class) Then
_Class_3 = ""
End If
If IsDBNull(_reg_info.fri_class) Then
_Class_4 = ""
End If
'Dim pdfpath As String = Server.MapPath("PDFs")
'Dim imagepath As String = Server.MapPath("Images")
Dim pdfpath As String = "C:\temp\"
Dim imagepath As String = "C:\temp\"
Dim doc As New Document
doc.SetPageSize(iTextSharp.text.PageSize.A4)
doc.SetMargins(0, 0, 2, 2)
Try
Dim writer As PdfWriter = PdfWriter.GetInstance(doc, New FileStream(pdfpath + "/Images.pdf", FileMode.Create))
doc.Open()
Dim cb As PdfContentByte = writer.DirectContent
cb.BeginText()
cb.SetTextMatrix(100, 400)
cb.ShowText(_LastName)
cb.EndText()
doc.Add(New Paragraph("JPG"))
Dim jpg As Image = Image.GetInstance(imagepath + "/Asads_Tags.jpg")
jpg.Alignment = iTextSharp.text.Image.UNDERLYING
jpg.ScaleToFit(576, 756)
doc.Add(jpg)
Catch dex As DocumentException
Response.Write(dex.Message)
Catch ioex As IOException
Response.Write(ioex.Message)
Catch ex As Exception
Response.Write(ex.Message)
Finally
doc.Close()
End Try
Return RedirectToAction("Index")
End Function
Anyone know where I could be going wrong at??????
The Try Catch block is what caused the unbalanced start/end exception.....Once I moved the doc.close() up to the bottom of try the error went away... Oh well maybe someone else will need the insight... –

Resources