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()
Related
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
I added a filter method which is filter by department by select the combo box options, however, I have no idea about how to push the data into the list after query from database. Below is my code.
Private Sub comboDept_Click()
Dim sQuery As String
Dim oRS As New ADODB.Recordset
Dim oRS_PR As New ADODB.Recordset
Dim sPONO As String
Dim sPOAmt As String
combVal = comboDept.List(comboDept.ListIndex)
If combVal = "EIBU_SALES" Then
sQuery = "Select PO_No, PO_Requestor, PO_Req_Dept, PO_Status, PO_Approval_M, PO_Approval_GM, PO_Approval_D, PO_HRApproval, VC_No, TH_Sup_Inv, PO_HR_Rmk, PO_Req_Date, PO_SupplierName, PO_OverallAmt from PR_INFO where PO_Req_Dept = '" & combVal & "'"
oRS_PR.Open sQuery, PRCnn, adOpenDynamic, adLockOptimistic
ElseIf comboDept.List(comboDept.ListIndex) = "MCBU_SALES" Then
Try something like this (it's just a hint; you have to adjust the code):
' Empty list
myListView.ListItems.Clear
' Add items
While (Not oRS_PR.EOF)
Set item = myListView.ListItems.Add(, , oRS_PR!FIRST_COLUMN)
item.SubItems(...) = oRS_PR!SOME_COLUMN
item.SubItems(...) = oRS_PR!OTHER_COLUMN
oRS_PR.MoveNext
Wend
I am working on a system right now in which When I put some value in my first text box (For eg. A primary key), I want the other textboxes to fetch the related data from my database and automatically get filled with it. I'm working on visual basic. I am new to this. For some Reason, it keeps on telling me that datarowcollection cannot be converted to string. Please help me get his working.
Here is the code:-
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
Dim Cn As New SqlClient.SqlConnection("Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename='C:\Users\admin\Documents\Asset_Manager.mdf';Integrated Security=True;Connect Timeout=30")
Dim StrCmd As String = "Select * from Asset_Master where Asset_Id= '" & txt_allocate_asset_id.Text & "' "
Dim Command As SqlCommand
Dim da As SqlDataAdapter
Dim dt As New DataTable
Try
Cn.Open()
Command = New SqlCommand(StrCmd, Cn)
da = New SqlDataAdapter(Command)
Command.ExecuteNonQuery()
da.Fill(dt)
txt_demo_model_no.Text = dt.Rows[0][model_no].ToString()//The error line
Catch ex As Exception
Throw ex
End Try
End Sub
I am developing winform application in vb6. I am using crystal report 4.6. I have created a crystal report which shows all data from a table (MS Access). And I unchecked save data with report and i saved the report. I just want to invoke it in application. So I included the component CrystalReportControl in my application. Now i want to set the records to be displayed in the report. The records are selected according to the user input to the text box.
Records are retrived from the database is done in following code.
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub Command1_Click()
Set conn = New ADODB.Connection
conn.Open "provider=Microsoft.jet.oledb.4.0;Data Source=" & App.Path &"\faculty.mdb"
Set rs = New ADODB.Recordset
rs.Open "select * from facultydetails where eid=1234", conn, adOpenDynamic, adLockPessimistic
CrystalReport1.ReportFileName = App.Path & "\faculty.rpt"
Set CrystalReport1.DataSource = rs
CrystalReport1.Action = 1
End Sub
Gives an error for the line: Set CrystalReport1.DataSource = rs :
as Property is write-only.
Tell me how the records of the report can be dynamic? Plz help me...
Instead of
Set CrystalReport1.DataSource = rs
do
CrystalReport1.DataSource = rs
EDIT:
Take a look at the following example and see if that will help you:
'CrystalReport1 is the name of the dsr file
Dim Report As New CrystalReport1
Dim cdoRowset As CrystalDataObject.CrystalComObject
Dim varArray() As Variant
'Open ADO Connection
Set m_cnAdo = New ADODB.Connection
m_cnAdo.ConnectionString = "DRIVER={SQL Server};UID=[UserID];PWD=[Password]" _
& ";SERVER=[Server];DATABASE=[Database]"
m_cnAdo.Open
Dim rsAdo As ADODB.Recordset
Dim cmdAdo As ADODB.Command
'Using Embedded Query
Set cmdAdo = New ADODB.Command
Set rsAdo = New ADODB.Recordset
cmdAdo.ActiveConnection = m_cnAdo
cmdAdo.CommandText = "SELECT * FROM Table WHERE Param = " & lngParam1
cmdAdo.CommandType = adCmdText
Set rsAdo = cmdAdo.Execute
Report.Database.SetDataSource rsAdo, 3, 1
The idea was to create a message box that stores my user name, message, and post datetime into the database as messages are sent.
Soon came to realize, what if the user changed his name?
So I decided to use the user id (icn) to identify the message poster instead. However, my chunk of codes keep giving me the same error. Says that there are no rows in the dataset ds2.
I've tried my Query on my SQL and it works perfectly so I really really need help to spot the error in my chunk of codes here.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim name As String
Dim icn As String
Dim message As String
Dim time As String
Dim tags As String = ""
Dim strConn As System.Configuration.ConnectionStringSettings
strConn = ConfigurationManager.ConnectionStrings("ufadb")
Dim conn As SqlConnection = New SqlConnection(strConn.ToString())
Dim cmd As New SqlCommand("Select * From Message", conn)
Dim daMessages As SqlDataAdapter = New SqlDataAdapter(cmd)
Dim ds As New DataSet
cmd.Connection.Open()
daMessages.Fill(ds, "Messages")
cmd.Connection.Close()
If ds.Tables("Messages").Rows.Count > 0 Then
Dim n As Integer = ds.Tables("Messages").Rows.Count
Dim i As Integer
For i = 0 To n - 1
icn = ds.Tables("Messages").Rows(i).Item("icn")
Dim cmd2 As New SqlCommand("SELECT name FROM Member inner join Message ON Member.icn = Message.icn WHERE message.icn = #icn", conn)
cmd2.Parameters.AddWithValue("#icn", icn)
Dim daName As SqlDataAdapter = New SqlDataAdapter(cmd2)
Dim ds2 As New DataSet
cmd2.Connection.Open()
daName.Fill(ds2, "PosterName")
cmd2.Connection.Close()
name = ds2.Tables("PosterName").Rows(0).Item("name")
message = ds.Tables("Messages").Rows(i).Item("message")
time = ds.Tables("Messages").Rows(i).Item("timePosted")
tags = time + vbCrLf + name + ": " + vbCrLf + message + vbCrLf + tags
Next
txtBoard.Text = tags
Else
txtBoard.Text = "nothing to display"
End If
End Sub
Would it be more efficient to combine both cmd and cmd2, such that cmd becomes
SELECT msg.*,mem.Name FROM Message msg INNER JOIN Member mem ON msg.icn = mem.icn ?
This way, your Member.name would be in the same dataset as your Messages table, making your code much cleaner.
-Joel