I have a VB.net application that has datagridviews and date control in windows forms. I have the short date format set in the date controls and short date format is some columns of the datagridview.
If I run the application on server 2008 it picks up the wrong short date format. I have the server 2008 regional settings as "en-AU" but for some reason the app picks up en-US as the current culture.
If I run the app as the Administrator it seems to pick up the proper culture.
Can anyone give me a reason as to why it could be doing that?
I tried setting the locale manually by doing
Dim c As Globalization.CultureInfo = New Globalization.CultureInfo(_Culture)
System.Threading.Thread.CurrentThread.CurrentCulture = c
System.Threading.Thread.CurrentThread.CurrentUICulture = c
But the same results.
Regards,
Dasith
What if you specifically set the culture?
Dim c As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("en-US", False)
That goes in the _Load sub of your main form.
Related
I am developing a VB.NET update system for a volunteer organisation’s MS Access database. The database is protected by a password as it contains personal information. I have created the application using the VB designer. I need to be able to code the application so that, if the owner decides to change the MS Access password, they will have no need to come back to me to change the code and rebuild the solution. In other words, I do not want the password to be hard coded in the app.config file or the settings.designer.vb file. My code should not need to know the password as a simple call to one of the Fill functions can test any password entered by the user. My problem is that I have found no way to alter the connection string that is tested in the setttings.designer.vb code whenever the database is accessed. I am using Visual Studio 2017.
I have spent a long time searching the web for answers and have tried various solutions involving the configurationmanager without success. I am new to this area so I would be most grateful if anyone here can help.
Here is my latest attempt which still produces an invalid password error even though the third debug statement suggests that the connection string, including the password, has been correctly set.
Public Sub UpdateConnString(connString As String)
Dim configFileMap As New ExeConfigurationFileMap()
Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(configFileMap.ExeConfigFilename)
Dim connStringName As String = "TestConnectionString"
Debug.Print("0 " + config.ConnectionStrings.ConnectionStrings(connStringName).ConnectionString)
config.ConnectionStrings.ConnectionStrings(connStringName).ConnectionString = connString
Debug.Print("1 " + config.ConnectionStrings.ConnectionStrings(connStringName).ConnectionString)
config.Save(ConfigurationSaveMode.Modified, True)
Debug.Print("2 " + config.ConnectionStrings.ConnectionStrings(connStringName).ConnectionString)
End Sub
Just because a connection string is stored in the config file, you aren't required to use it as it is. You can read in that default value and then edit it before using it, e.g.
Dim builder As New OleDbConnectionStringBuilder(My.Settings.DefaultConnectionString)
builder.DataSource = dataSource
Dim connectionString = builder.ConnectionString
You can add or modify any part of a connection string you want that way at run time.
Thank you for your response. Unfortunately, the code throws a compilation error - "DefaultConnectionString is not a member of My.Settings".
Fortunatley I have now managed to find a working solution:
'My.Settings.Item("TestConnectionString") = connectionString
I have a database that contains the data as in the following picture
Notes:
Collation Database ('SQL_Latin1.General_CP1_CI_AS').
I have no right to change Collation to Araic_CI_AS.
In case you change Collation to Araic_CI_AS, the data display from the database is displayed in the new program, but the program has a problem and it appears in the old program in the form of ????? Where the old program.
I can not modify the old program because there is no source code for it.
This database is outdated and may not be modified by anyone ( Collation [rows] or Collation [databases])
When you link the database to a new standalone program through Visual Basic 2015 to use some data from the database, the following format appears as in the picture...
What I want is to display the content of the database to change the (ãßÇÆä æÂáÇÊ) sentence to the default language which is Arabic.
I hope to find a solution through the Visual Basic code and not through the amendment to the database.
Thanks to all
The problem has been solved in the process of converting the encoding characters by the following code:
Private Function conv1256(ByVal txt As String) As String
Dim dic As New Dictionary(Of String, String)
Const _1256 As String = "ÐÏÌÍÎåÚÛÝÞËÕÖØßãäÊÇáÈíÓÔÙÒæÉìÑÄÁÆøºÅñõðó¡ÜÃòö¿Âú"
Const _utf8 As String = "ذدجحخهعغفقثصضطكمنتالبيسشظزوةىرؤءئّ؛إًٌَُ،ـأٍِ؟آْ"
For i = 0 To (_1256.Length) - 1
dic.Add(_1256.Chars(i), _utf8.Chars(i))
Next i
For Each ch In txt
conv1256 &= If(dic.ContainsKey(ch), dic.Item(ch), ch)
Next
End Function
To be used this way:
MsgBox(conv1256("ÈÓãö Çááå ÇáÑøÍãä ÇáÑøÍíã"))
Good luck and thank you all
I'm trying to create new computers and add them to OU using vb.net. Everything is fine except the Primary-Group-ID and sAMAccounType attributes. These two attributes show that I'm actually creating users instead of computers so this is the problem.
Here is my code:
Dim oldentry = New DirectoryEntry(SpecificOU, securedusername, securedpassowrd)
Dim newentry As DirectoryEntry = oldentry.Children.Add("CN=" & CumputerName, "Computer")
newentry.Properties("sAMAccountName").Value = "" + CumputerName& "$" + ""
newentry.CommitChanges()
newentry.Close()
newentry.Dispose()
I can find the computer created but the only difference is that this "computer" is actually normal user account. Since I cannot set the properties for primaryGroupID and sAMAccountType, I don't know what to do right now.
Okay I figured it out. I need to add one more property so it now works
newentry.Properties("userAccountControl").Value = &H1020
&H1020 is equivalent to 0x1020 in hex format, which means workstation trusted account and password not required. Value will vary depending on specific circumstances.
https://support.microsoft.com/en-ca/help/305144/how-to-use-the-useraccountcontrol-flags-to-manipulate-user-account-pro
I'm trying to set the timezone for an aplication that is supposed to run in .net compact framework and i'm getting a little bit o trouble to get it right.
I want to set it to GMT Standard Time but for some reason i keep getting the Monrovia, Reyqjavik Timezone:
Here is my code (Im using Opennet class):
Dim TZC As New TimeZoneCollection
TZC.Initialize(0)
For Each tzi As TimeZoneInformation In TZC
If tzi.StandardName = "GMT Standard Time" Then
Application.DoEvents()
DateTimeHelper.SetTimeZoneInformation(tzi)
Exit For
End If
Next
For some reason it keeps setting it to Monrovia instead of London Timezone
Can anyone help? Thanks!
I made a small VB.NET application which includes a Crystal Report. Running the Crystal Report on the machine I made it works perfectly. When I run the application on my laptop, the Crystal Report always prompts me for a login eventhough the database has no login set to it. I have tried passing in "Admin" and "" with code, but no luck.
I'm working with an Access database, this is the code I have to load my Crystal Report:
If frmReport Is Nothing OrElse frmReport.IsDisposed Then
frmReport = New frmReport
End If
frmReport.CrystalReportViewer1.ReportSource = "../../Reports/Klantenbeheer.rpt"
frmReport.MdiParent = Me
frmReport.Show()
I did look at Prevent login of ODBC Text driver in Crystal Report for Visual Studio 2010 but I'm not sure if it applies to my situation?
I also tried setting the rpt's datasource to the datasource I work with in the application and then assigning that to the ReportSource, but no luck either.
Some people found a solution in changing from DAO to OLEDB, but I have used OLEDB from the beginning.
Perhaps the code found in at the bottom of this thread could help you? Specifically:
Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine
Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()
Dim myReport As New ReportDocument()
myReport.Load(Server.MapPath("ReportName")) 'name of your Crystal Report - see note below
Dim myTables As Tables = myReport.Database.Tables
For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables
Dim myTableLogonInfo As TableLogOnInfo = myTable.LogOnInfo
myConnectionInfo.ServerName = <SQL servername>
myConnectionInfo.DatabaseName = "" 'leave database name blank
myConnectionInfo.UserID = 'login name
myConnectionInfo.Password = 'password
myTableLogonInfo.ConnectionInfo = myConnectionInfo
myTable.ApplyLogOnInfo(myTableLogonInfo)
Next
CrystalReportViewer1.ReportSource = myReport
It is made for ASP.Net, but might work with minor adjustments?
Well, I know it's an old question. But I think I should just add an info that, I got a link that, after painful research, he tell that, we must copy the correct version of crdb_ado.dll. Read it here : XtremeNetTalk. Unfortunately, I haven't been able to locate that file yet in the internet! I hope I can complete this answer with this.