I was able to add an sqlDataSource and make it work in the Design view but I would like to do it in the code but that's where I can't seem to make it work.
I have Visual Studio 2012 and SQL Server Compact Edition 4.0 installed on my pc. I think there's an error in my Connection String but that's just my opinion, it looks something like this :
"Data Source=\"C:\\Users\\MyUser\\Documents\\Visual Studio 2012\\Databases\\Database.sdf\";Password=MyPassword;Persist Security Info=True"
But honestly if even I get the connection string right, I'm kind of in the dark on where to go after that, so if you would have any tips or even good tutorials on that, it would help a bunch.
If the problem isn't my ConnectionString then it must be somewhere else or I'm just not doing it right so here's the rest of my code :
sqlDataSourceDB.SelectCommand = "SELECT * FROM quote";
DataView dv = (DataView)sqlDataSourceDB.Select(DataSourceSelectArguments.Empty);
String resultat = (String)dv.Table.Rows[0][0];
The two last lines were taken from an msdn mini walkthrough
Une erreur liée au réseau ou spécifique à l'instance s'est produite lors de l'établissement d'une connexion à SQL Server. Le serveur est introuvable ou n'est pas accessible. Vérifiez que le nom de l'instance est correct et que SQL Server est configuré pour autoriser les connexions distantes. (provider: SQL Network Interfaces, error: 26 - Erreur lors de la localisation du serveur/de l'instance spécifiés)
The error looks like that (it is translated from french) :
An error liked to the network or the instance happened when establishing a connection to SQL Server.
The server is not found or cannot be accessed.
Check that the instance name is correct and that the SQL Server is correctly configured to allow distant connection.
(provider: SQL Network Interfaces, error 26 - Error when locating the server/instance)
RESOLVED : Alright, I realized that in Design View when I added the SqlDataSource it was working but not when I was coding it so I checked the full line and just saw my own stupidity; I had to specify the ProviderName -.- everything worked after that. Story lesson here, always overcheck everything instead of making stupid post. Thanks for the help though!
You add in your connection string to the config file which is included with every new project in visual studio like so:
<connectionStrings>
<add name="main" connectionString="Data Source=\"C:\\Users\\MyUser\\Documents\\Visual Studio 2012\\Databases\\Database.sdf\";Password=MyPassword;Persist Security Info=True" />
</connectionStrings>
The tutorial below makes use of something slightly different so it's up to you how you implement depending on your environment.
And your code behind file: (You will need to import SqlServerCe namespace)
string sql = "select * from blah";
SqlCeCommand cmd = new SqlCeCommand(sql, ConfigurationManager.ConnectionStrings["main"].ConnectionString);
SqlCeDataAdapter da = new SqlCeDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
foreach(DataRow r in dt.Rows)
{
Console.WriteLine(r["something"].ToString());
}
Full tutorial on Sql Compact Edition at dotnetperls: http://www.dotnetperls.com/sqlce. The tutorial uses a reader to print the data out to the console, but you can just fill a DataTable like I have above quite as easily.
Related
Error is happening in the code shown here.
I tried the following based on google research, but still error persists
Ensured "LDAP" is in upper case
Installed II6 meatabase 6.
Error goes off if Application pool or IIS is restarted. But after a day, it comes back. any help is appreciated.
DE = new DirectoryEntry("LDAP://iaai.com/DC=iaai,DC=com");
AdSearch = new DirectorySearcher(DE);
AdSearch.Filter = string.Format("(&(objectClass=user)(objectCategory=user) (sAMAccountName={0}))", sAcct);
AdSearch.PropertiesToLoad.Add("userprincipalname");
AdResult = AdSearch.FindOne();
Error 0x80005000 may be caused by permission issues, Plus the parameters for the user name and password should be set to string or "Nothing" and not nothing.
DE = new DirectoryEntry("LDAP://iaai.com/DC=iaai,DC=com", userName, password);
I'm having issues with creating a certificate to use with XAMPP. I've been looking everywhere for a solution but I can't seem to find one that works for me.
So I'm following this guide (reading to the comments not a lot of people are happy with it tho but I don't find anything else): https://gist.github.com/nguyenanhtu/33aa7ffb6c36fdc110ea8624eeb51e69
And in the first step they ask you to run the makecert.bat that's located in the C:\xampp\apache directory.
When I run it I get this error:
Generating a 2048 bit RSA private key
......................+++
........+++
writing new private key to 'privkey.pem'
Enter PEM pass phrase:testen
2684:error:28069065:lib(40):UI_set_result:result too small:.\crypto\ui\ui_lib.c:831:You must type in 4 to 511 characters
2684:error:0906406D:PEM routines:PEM_def_callback:problems getting password:.\crypto\pem\pem_lib.c:116:
2684:error:0907E06F:PEM routines:DO_PK8PKEY:read key:.\crypto\pem\pem_pk8.c:130:
unable to load Private Key
1204:error:0906D06C:PEM routines:PEM_read_bio:no start line:.\crypto\pem\pem_lib.c:708:Expecting: ANY PRIVATE KEY
server.csr: No such file or directory
Could Not Find C:\xampp\apache\server.csr
Het systeem kan het opgegeven bestand niet vinden.
Het systeem kan het opgegeven bestand niet vinden.
-----
Das Zertifikat wurde erstellt.
The certificate was provided.
As it says, there is no server.csr located in that directory, it's located under \xampp\apache\conf\ssl.csr
If I go to chrome and go to https://localhost/project I get the warning that the connection is not secure, if I click on advanced and move on I can continue on https eventhough the browser doesn't show the green safe thingy.
Problem is I'm working on with a woocommerce shop and the API, the API needs a secure connection.
Anyone that can help me solve this issue please? Thank you! I'm eager to learn. :)
I am working on IIS 7, SQL Express 2008.
I'm trying to use the Web Site Administration Tool to set up some users in a membership db. I have the tables set up but when I click on the security tab in the web app I get an exception "There is a problem with your selected data store..." the error i get is
"The following message may help in diagnosing the problem: Cannot open database "ticketinventory" requested by the login. The login failed. Login failed for user 'sa'"
The connection string I am using is "data source=kyrian-pc\sqlexpress;Initial Catalog=ticketinventory;Persist Security Info=True;User ID=sa;Password=******;"
(I know to not use sa for a connection string, this is just to get it to work initially and I have removed the password with ** )
I can log into sql with the sa username and password and query the membership tables. If I change the querystring to a fake user name I see the error message in the web app reflect that username so I know it is using the right connection string.
As far as I can tell this should be working but I am obviously missing something. Any ideas?
EDIT
It turns out the issue has something to do with my connection string itself. I created a test page with this code
using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString))
{
conn.Open();
conn.Close();
}
and this throws a login exception. For whatever reason my other connection string are being stored in the appSettings so there is some difference that I am now trying to work out.
Despite checking it 5 or 6 times I had the db name wrong in the connection string. Problem solved.
"The only infinite things are is the universe itself and the stupidity of man, and I'm not sure about the 1st one" - einstein
I'm working with outlook and I got a problem.
I dont know why and how, but my outlook project lost the Certificate.
so I go on vba->tool->tools->Personal Digital Signature
I set a Certificate.
I try to save and got an error.
in french "Une erreur est survenue lors de la signature du projet. Le projet non-signé a été enregistré."
this means : an error occurred during Signature of the project. the project unsigned has been saved.
after the digital sign is empty.
and I still cant use macro.
I dont know what to do.
help me
I found a way: I use an old VbaProject.OTM.
I'm trying to write a simple website (ASP.NET v4), which will call Windows Search, find a specific file and return it to the user. I've put together the following as an example: it calls the Windows Search service on "remoteserver", and returns the path of "somefile.txt":
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';";
OleDbCommand cmd = conn.CreateCommand();
cmd.CommandText = string.Format(
"SELECT System.ItemPathDisplay, System.ItemType FROM " +
" sytelhp.systemindex WHERE SCOPE='file://remoteserver/archive' AND CONTAINS(\"System.FileName\", " +
" '\"*{0}*\"')", "somefile.txt");
conn.Open();
OleDbDataReader rdr = cmd.ExecuteReader();
string result=rdr[0].ToString();
.. and this works great on Visual Studio 2010 development environment, "result" contains the path to the file. However, if I deploy it to the local IIS7 server (running on Server 2008), I get this error:
The parameter is incorrect.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: The parameter is incorrect.
I'm at a loss where to go next. What do I need to do to IIS7, or the code, or both to get it working? Again, this works fine within VS2010 (tested on both Windows 7 and Windows 2008 Server).
I guess you are running on Vista or older OS and the IIS runs on 2008 Server or newer?
Try Provider=Search.CollatorDSO.1 (note the .1).
Edit: You should use a different user account for the search to work (not the default "network service" one the asp.net app runs under). See the comments for more info.