Notes error: Could not open the ID file in lotus notes - vb.net

Please somebody help me. I use Lotus Notes to send email with using vb.net but I got this error when I try to run. I already add references about interop.lotus.dll and interop.Domino.dll but it's still the same error. Please advice..
Line 115: If dsEmail.Tables(0).Rows.Count > 0 Then
Line 116: **s.Initialize("abcde!")** 'ERROR in THIS LINE
Protected Sub btnSend_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSend.ServerClick
Dim s As New Domino.NotesSession
Dim db As Domino.NotesDatabase
Dim doc As Domino.NotesDocument
Dim mimeEntity As Domino.NotesMIMEEntity
Dim mimeChild As Domino.NotesMIMEEntity
Dim header As Domino.NotesMIMEHeader
Dim stream As Domino.NotesStream
Dim sendTo As String
Dim connectionString As String = "Data Source=[hide];User ID=[hide];initial Catalog=[hide];Password=[hide]"
Dim objConn As New SqlConnection(connectionString)
objConn.Open()
Dim dsEmail = New DataSet
Dim CommTaskA As SqlCommand
Dim AdapTaskA As SqlDataAdapter
CommTaskA = New SqlCommand("select EMAILBLASTCCID, rtrim(ltrim(EMAILADDR)) EMAILADDR, SUBJECTEMAIL, EMAILTEMPLATE from [hide] where [MESSAGE_TIME] is NULL", objConn)
CommTaskA.CommandTimeout = 180
AdapTaskA = New SqlDataAdapter
AdapTaskA.SelectCommand = CommTaskA
AdapTaskA.Fill(dsEmail)
AdapTaskA.Dispose()
CommTaskA.Dispose()
objConn.Close()
If dsEmail.Tables(0).Rows.Count > 0 Then
s.Initialize("abcde!")
db = s.GetDatabase("[hide]", "[hide].nsf", False)
subjectEmail = dsEmail.Tables(0).Rows(0)(2).ToString
For x As Integer = 0 To dsEmail.Tables(0).Rows.Count - 1
doc = db.CreateDocument()
sendTo = dsEmail.Tables(0).Rows(x)(1).ToString
doc.ReplaceItemValue("SendTo", dsEmail.Tables(0).Rows(x)(1))
doc.ReplaceItemValue("Subject", dsEmail.Tables(0).Rows(x)(2))
mimeEntity = doc.CreateMIMEEntity
mimeChild = mimeEntity.CreateChildEntity
header = mimeEntity.GetNthHeader("Content-Type")
header.SetHeaderVal("multipart/related")
stream = s.CreateStream
stream.WriteText("<img src='" & dsEmail.Tables(0).Rows(x)(3) & "'>")
mimeChild.SetContentFromText(stream, "text/html", Domino.MIME_ENCODING.ENC_NONE)
stream.Close()
doc.Send(False)
objConn.Open()
CommTaskA = New SqlCommand("update [ZITA].[DEV].[EMAILBLASTCC_test] set [MESSAGE_TIME] ='" & DateTime.Now.ToString & "' where rtrim(ltrim(EMAILADDR)) = '" & sendTo & "'", objConn)
CommTaskA.CommandTimeout = 180
CommTaskA.ExecuteNonQuery()
CommTaskA.Dispose()
objConn.Close()
Next
End If
End Sub

Thank you for all your respond.. I found the answer
the problem because the user account Lotus Notes and my IIS Manager are different.
You must make your Lotus Notes IBM and Application Pool Identity in IIS Manager run with the same account.
It works for me. Thank You

Make sure the Windows environment variable PATH points to C:\Users\adventina.nababan\AppData\Local\IBM\Notes\Data\ too.
For further instructions on how to do this, please take a look at the question "Adding directory to PATH Environment Variable in Windows".

Related

sqldatareader which must be closed error but it has not been used?

All,
This is my code:
Public Class frmFindRoute
Private Sub frmFindRoute_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim cmdroad As SqlCommand
Dim sdrroad As SqlDataReader
cmdroad = conRouteMapping.CreateCommand
cmdroad.CommandText = "Select title, uniqueref from road order by title"
sdrroad = cmdroad.ExecuteReader
PopulateListviewHeaders(lvwFromRoad, 1, sdrroad)
PopulateListview(lvwFromRoad, sdrroad)
sdrroad = cmdroad.ExecuteReader
PopulateListviewHeaders(lvwToRoad, 1, sdrroad)
PopulateListview(lvwToRoad, sdrroad)
sdrroad.Close()
End Sub
Private Sub cmbFind_Click(sender As Object, e As EventArgs) Handles cmbFind.Click
Dim cmdLanes As SqlCommand
Dim sdrLanes As SqlDataReader
cmdLanes = conRouteMapping.CreateCommand
cmdLanes.CommandText = "Select direction, number,uniqueref from lane where roadref='" & lvwFromRoad.SelectedItems(0).SubItems(1).Text & "'"
sdrLanes = cmdLanes.ExecuteReader
sdrLanes.Read()
FindRoute(sdrLanes.GetValue(2))
End Sub
Private Sub FindRoute(ByVal LaneRef As Guid)
Dim cmdDestRoad As SqlCommand
Dim sdrDestRoad As SqlDataReader
Dim cmdNextJunction As SqlCommand
Dim sdrNextJunction As SqlDataReader
cmdDestRoad = conRouteMapping.CreateCommand
cmdDestRoad.CommandText = "Select roadref from lane where uniqueref='" & LaneRef.ToString & "'"
sdrDestRoad = cmdDestRoad.ExecuteReader ' << error here
If sdrDestRoad.GetValue(0) <> lvwToRoad.SelectedItems(1).SubItems(0).Text Then
cmdNextJunction = conRouteMapping.CreateCommand
cmdNextJunction.CommandText = "Select tolane from junction where fromlane='" & LaneRef.ToString & "'"
sdrNextJunction = cmdNextJunction.ExecuteReader
Do While sdrNextJunction.Read
'FindRoute(sdrNextJunction.GetValue(0))
Loop
sdrNextJunction.Close()
End If
sdrDestRoad.Close()
End Sub
End Class
Where I've marked "error here" I get the error:
There is already an open DataReader associated with this Command which
must be closed.
I don't know why? I've already verified that cmdDestRoad and sdrNextJunction aren't used anywhere else in the solution. The data readers in form_load and find_click work fine.
I've also used breakpoints to confirm that it fails the first time it runs this section of code.
Mary's answer was correct. You can not have two open readers on a connection. I can't accept it as answer as it's a comment.
The line
sdrDestRoad = cmdDestRoad.ExecuteReader
Fails because a reader is already opened with the following line in cmbFind_Click:
sdrLanes = cmdLanes.ExecuteReader
The lines:
cmdDestRoad = conRouteMapping.CreateCommand
cmdDestRoad.CommandText = "Select roadref from lane where uniqueref='" & LaneRef.ToString & "'"
are not part of the problem. Opening a second command on the connection didn't cause the error. Trying to open a second reader did.

vb.net import csv file to devexpress gridview

Currently Im facing problem in importing csv file to devexpress gridview,When i execute the code, the following error showed 'C:\New folder\QtimeAutomotiveByLot_new.csv' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides. and the filepath works perfectly fine on my side. my code is as follow, can anyone guide me on this?
asp.net
<dx:ASPxGridView ID="DetailGridx" runat="server" OnDataBinding="DetailGridx_DataBinding">
vb.net
Protected Sub DetailGridx_DataBinding(sender As Object, e As EventArgs)
Dim dt1 As New DataTable()
Dim csvFileFolder As String = "C:\New folder\QtimeAutomotiveByLot_New.csv"
'Dim csvFile As String = "QtimeAutomotiveByLot_New.csv"
Dim strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + csvFileFolder + ";Extended Properties='Text;HDR=YES;IMEX=1;';"
Dim connx As New OleDbConnection(strCon)
Dim adapter1 As New OleDbDataAdapter
connx.Open()
Dim sql As New OleDbCommand("Select * FROM [" + csvFileFolder + "]", connx)
adapter1.SelectCommand = sql
adapter1.Fill(dt1)
connx.Close()
Dim detailGrid As ASPxGridView = CType(sender, ASPxGridView)
Dim RowLotID As String = TryCast(sender, ASPxGridView).GetMasterRowFieldValues("LOTID")
Dim ddata As DataView = New DataView(dt1)
ddata.RowFilter = "LOTID = '" + RowLotID + "'"
detailGrid.DataSource = ddata
detailGrid.DataBind()
End Sub
Sounds like your current connection string to read CSV file is wrong. Unlike reading Excel files, when reading CSV files we're not specifying actual file name, but directory path where it belongs (see this issue).
The following example shows how to read CSV file using Jet 4.0 provider. Note that instead of setting IMEX=1, use FMT=Delimited property because IMEX primarily used for XLS and XLSX file format:
Protected Sub DetailGridx_DataBinding(sender As Object, e As EventArgs)
Dim dt1 As New DataTable()
Dim csvFileFolder As String = "C:\New folder\"
Dim csvFile As String = "QtimeAutomotiveByLot_New.csv"
' specify directory path containing CSV file as data source
Dim strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + csvFileFolder + ";Extended Properties='Text;HDR=YES;FMT=Delimited';"
Dim connx As New OleDbConnection(strCon)
Dim adapter1 As New OleDbDataAdapter
connx.Open()
' specify actual file name here
Dim sql As New OleDbCommand("Select * FROM [" + csvFile + "]", connx)
adapter1.SelectCommand = sql
adapter1.Fill(dt1)
connx.Close()
Dim detailGrid As ASPxGridView = CType(sender, ASPxGridView)
Dim RowLotID As String = TryCast(sender, ASPxGridView).GetMasterRowFieldValues("LOTID")
Dim ddata As DataView = New DataView(dt1)
ddata.RowFilter = "LOTID = '" + RowLotID + "'"
detailGrid.DataSource = ddata
detailGrid.DataBind()
End Sub

what is the correct format for calling a db in access, with a 'folder with spaces'?

Public connstring As String = "Provider = Microsoft.ACE.Oledb.12.0; Data Source = C:\Users\blablabla\Document\Visual Studio 2013\Project\rentalsystem\rental_db.accdb"
i placed this line of code under a module so i wont have to call it everytime. and this is the code that the code above is connected to...
Public Sub loadLVusers()
LVusers.Items.Clear()
Dim sqlcode As String = "select id_code, user_lastname, user_firstname, user_midname, user_username, user_password, user_email, user_privilege from tblUsers"
Dim sqlcomd As New OleDb.OleDbCommand(sqlcode)
sqlcomd.Connection = New OleDb.OleDbConnection(connstring)
sqlcomd.Connection.Open()
Dim DA As New OleDb.OleDbDataAdapter(sqlcomd)
Dim DS As New DataSet
DA.Fill(DS, "Pi")
If DS.Tables("Pi").Rows.Count > 0 Then
Dim Ic(100) As String
For r = 0 To DS.Tables("Pi").Rows.Count - 1
For c = 0 To DS.Tables("Pi").Columns.Count - 1
Ic(c) = DS.Tables("Pi").Rows(r)(c).ToString
Next
Dim LVI As New ListViewItem(Ic)
LVusers.Items.Add(LVI)
Next
End If
End Sub
now when the form/window that it is attached to loads, the form/window does not open. and then it highlights
sqlcomd.Connection = New OleDb.OleDbConnection(connstring)
so im guessing that has something to do with the file path format

VB.Net Question

I am working on a VB.Net project and trying to get it to pull data from a database. I have the data base located in my bin folder with in the project but I do not know the exact path how to do it. The code that I am using is noted below
Private Sub btnTotalTravelCost_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTotalTravelCost.Click
'strsql is a sql statement that selects all the fields from the
'ApprovedTravelRequest table
Dim strSql As String = "SELECT * FROM ApprovedTravelRequests "
'strPath provides the database type and path of the Travel database.
Dim strPath As String = "Provider=Microsoft.ACE.OLEDB.12.0 ;" & "Data Source=c:\Travel.accdb"
Dim odaTravel As New OleDb.OleDbDataAdapter(strSql, strPath)
Dim DatCost As New DataTable
Dim intCount As Integer
Dim decTotalCost As Decimal = 0D
'The DataTable name datCost is filled with the data
odaTravel.Fill(DatCost)
'The connection to the databsise is disconnected
odaTravel.Dispose()
For intCount = 0 To DatCost.Rows.Count - 1
decTotalCost += Convert.ToDecimal(DatCost.Rows(intCount)("Travel Cost"))
Next
Me.lblTotalTravelCost.Visible = True
Me.lblTotalTravelCost.Text = "The Total Approved Travel Cost is " & decTotalCost.ToString("C")
End Sub
End Class
Will someone be able to explain how to do this? I am wanting to pull the data from the Bin File. I know the current location shown is incorrect.
If the database is in the bin folder (with the executable), then you can do:
' Get the current directory (where the exe resides)
Dim folder As String = System.AppDomain.CurrentDomain.BaseDirectory
' Construct the full path to the DB (assuming it's with the exe)
folder = System.IO.Path.Combine(folder, "Travel.accdb")
' Build your connection string
Dim strPath As String = "Provider=Microsoft.ACE.OLEDB.12.0 ;" & "Data Source=" & folder
Dim strPath As String = "Provider=Microsoft.ACE.OLEDB.12.0 ;" & "Data Source=c:\Travel.accdb"
Dim strSql As String = "SELECT * FROM ApprovedTravelRequests"
Dim decTotalCost As Decimal = 0.0
Using connect As New OleDb.OleDbConnection(strPath)
Using command As New OleDb.OleDbCommand(strSql, connect)
connect.Open()
Using reader As OleDb.OleDbDataReader = command.ExecuteReader()
If reader.HasRows Then
While reader.Read()
decTotalCost += Convert.ToDecimal(reader(0))
End While
End If
Me.lblTotalTravelCost.Visible = True
Me.lblTotalTravelCost.Text = "The Total Approved Travel Cost is " & decTotalCost.ToString("C")
End Using
End Using
End Using

vb.net use string as a previously created object instance

Not sure exactly what I need to do to make this work, so my description may be lacking at first. Essentially I am writing a program launcher that recreates itself each time on load. It pulls the data regarding the tabs and buttons from an SQLite database and builds itself dynamically at run time. I get my problem when I pass the tab name through to the function that creates the buttons. I need the name to pull the right set of buttons from the database and I then tried to use the name to place the buttons on the right tab when I create them, but the debugger calls it a null reference because it doesn't point correctly to the tabpage that I'm trying to make it point to (at least that is what I'm guessing). Any ideas on how to make this work right?
Private Sub CreateTabs()
Dim SQLconnect As New SQLite.SQLiteConnection()
Dim SQLcommand As SQLiteCommand
SQLconnect.ConnectionString = "Data Source=" & sPath & "\dock.db;"
SQLconnect.Open()
SQLcommand = SQLconnect.CreateCommand
SQLcommand.CommandText = "SELECT title FROM tabs"
Dim SQLreader As SQLiteDataReader = SQLcommand.ExecuteReader()
Dim Tabs(25) As String
Dim c As Integer = 1
While SQLreader.Read()
Tabs(c) = SQLreader(0)
c = c + 1
End While
SQLcommand.Dispose()
SQLconnect.Close()
For i = 1 To UBound(Tabs)
If Tabs(i) <> "" Then
Launcher.TabPages.Add(Tabs(i))
CreateButtons(Tabs(i))
End If
Next
End Sub
Private Sub CreateButtons(ByVal tab)
Dim SQLconnect As New SQLite.SQLiteConnection()
Dim SQLcommand As SQLiteCommand
SQLconnect.ConnectionString = "Data Source=" & sPath & "\dock.db;"
SQLconnect.Open()
SQLcommand = SQLconnect.CreateCommand
SQLcommand.CommandText = "SELECT id,name,path FROM buttons WHERE tab = '" & tab & "'"
Dim SQLreader As SQLiteDataReader = SQLcommand.ExecuteReader()
While SQLreader.Read()
For i = 1 To 9
Dim NewButton(i) As Button
If Not SQLreader(2) Is System.DBNull.Value Then
Dim myIcon As System.Drawing.Icon = Icon.ExtractAssociatedIcon(SQLreader(2))
End If
Dim toolTip1 As ToolTip = New System.Windows.Forms.ToolTip(Me.components)
Me.Controls(tab).tabpages.add(NewButton(i)) '<--this causes my problem
'NewButton(i).Width = 32
'NewButton(i).Height = 32
'NewButton(i).Text = i
'NewButton(i).Image = myIcon.ToBitmap
'If Not SQLreader(1) Is System.DBNull.Value Then
'toolTip1.SetToolTip(NewButton(i), SQLreader(1))
'toolTip1.Active = True
'End If
Next
End While
SQLcommand.Dispose()
SQLconnect.Close()
End Sub
I think you've got two problems here:
You're trying to find the tab control by the tab name. You should instead find the tab control itself (or pass it in) and find the name of the tab inside that control. Otherwise you're trying to add a button to a collection of tab pages, instead of to a specific tab.
You're never actually creating a new button. You're creating an array of buttons for every iteration of the loop, but not a new actual Button object. Admittedly that doesn't jibe with your suspicion that it's due to tab pages, but it's certainly a problem...
I suspect you want this as your loop (where tabControl is the TabControl passed in):
While SQLreader.Read()
For i = 1 To 9
If Not SQLreader(2) Is System.DBNull.Value Then
Dim myIcon As Icon = Icon.ExtractAssociatedIcon(SQLreader(2))
End If
Dim toolTip1 As ToolTip = New ToolTip(Me.components)
Dim NewButton As Button = New Button
NewButton.Width = 32
NewButton.Height = 32
NewButton.Text = i
NewButton.Image = myIcon.ToBitmap
tabControl.TabPages(tab).Controls.Add(NewButton)
If Not SQLreader(1) Is System.DBNull.Value Then
toolTip1.SetToolTip(NewButton, SQLreader(1))
toolTip1.Active = True
End If
Next
End While
Hopefully that's right - my VB.NET isn't great...
I'm surprised your original code compiled though - do you have Option Strict on?
You should also use a Using statement for your command and connection so they get disposed even when an exception occurs.
Thanks for the help, but I found my answer. Apparently I just needed to reference the index of the tab like so:
Private Sub CreateTabs()
Dim SQLconnect As New SQLite.SQLiteConnection()
Dim SQLcommand As SQLiteCommand
SQLconnect.ConnectionString = "Data Source=" & sPath & "\dock.db;"
SQLconnect.Open()
SQLcommand = SQLconnect.CreateCommand
SQLcommand.CommandText = "SELECT title FROM tabs"
Dim SQLreader As SQLiteDataReader = SQLcommand.ExecuteReader()
Dim Tabs(25) As String
Dim c As Integer = 1
While SQLreader.Read()
Tabs(c) = SQLreader(0)
c = c + 1
End While
SQLcommand.Dispose()
SQLconnect.Close()
For i = 1 To UBound(Tabs)
If Tabs(i) <> "" Then
Launcher.TabPages.Add(Tabs(i))
CreateButtons(Tabs(i), i - 1)
End If
Next
End Sub
Private Sub CreateButtons(ByVal tab, ByVal TabIndex)
Dim SQLconnect As New SQLite.SQLiteConnection()
Dim SQLcommand As SQLiteCommand
SQLconnect.ConnectionString = "Data Source=" & sPath & "\dock.db;"
SQLconnect.Open()
SQLcommand = SQLconnect.CreateCommand
SQLcommand.CommandText = "SELECT id,name,path FROM buttons WHERE tab = '" & tab & "'"
Dim SQLreader As SQLiteDataReader = SQLcommand.ExecuteReader()
While SQLreader.Read()
For i = 1 To 9
Dim NewButton As New Button
Launcher.TabPages.Item(TabIndex).Controls.add(NewButton)
NewButton.Width = 32
NewButton.Height = 32
NewButton.Location = New Point(10 + (SQLreader(0) * 32) + 10, 10)
NewButton.Text = SQLreader(0)
If Not SQLreader(2) Is System.DBNull.Value Then
Dim toolTip1 As ToolTip = New System.Windows.Forms.ToolTip(Me.components)
Dim myIcon As System.Drawing.Icon = Icon.ExtractAssociatedIcon(SQLreader(2))
NewButton.Image = myIcon.ToBitmap
toolTip1.SetToolTip(NewButton, SQLreader(1))
toolTip1.Active = True
End If
Next
End While
SQLcommand.Dispose()
SQLconnect.Close()
End Sub