I'm getting the following error:
HTTP Error 404.0 - Not Found The resource you are looking for has been
removed, had its name changed, or is temporarily unavailable
with the following code:
SqlConnection cn = new SqlConnection(#"Data Source=bpnaidu-pc\sqlexpress;Initial Catalog=UserLogIn;Integrated Security=True;Pooling=False");
cn.Open();
SqlCommand cmd = new SqlCommand( "INSERT INTO regd values('" + ddl_signup.Text + "','" + txt_user.Text + "','" + txtEmail1.Text+ "','" + txtPassword.Text + "','" + txtConPassword.Text + "')", cn);
cmd.ExecuteNonQuery();
Response.Redirect("welcome to "+txt_user.Text.ToString());
Response.Redirect("Home.aspx");
cn.Close();
Where is the problem?
Although the question isn't directly clear, the answer is. The problem is on this line:
Response.Redirect("welcome to "+txt_user.Text.ToString());
Response.Redirect sends a browser to the webpage specified in the parameter, so you're trying to send the browser to a page called "welcome to {...}". I find this unlikely. I suspect what you really want is:
Response.Write("welcome to "+txt_user.Text.ToString());
Response.Write just sends a text string straight into the HTTP output buffer.
However you follow this up immediately with a redirect to Home.aspx, so in reality the line actually does nothing as no sooner have you written the output out that you tell the browser to redirect to a different page, so the user will not see your welcome message.
I'd also like to point out that you're open to a SQL Injection attack as well - your line:
SqlCommand cmd = new SqlCommand( "INSERT INTO regd values('" + ddl_signup.Text + "','" + txt_user.Text + "','" + txtEmail1.Text+ "','" + txtPassword.Text + "','" + txtConPassword.Text + "')", cn);
...is open to a user doing bad things; if txt_user.Text contains the text '); drop table regd; there's a good chance you'll end up with a missing regd table. To fix, you need to use parameterised SQL statements. Rather than correct this here, I strongly recommend you follow up by reading Jeff Atwood's blog article about this and how to mitigate.
Related
I am creating a message inside a string using a Script task
The code would look like this:
Message = Description +"\n" + Message;
The idea is to receive a message like this:
Description
Description
and so on
Within a messagebox I can see this result, but when I open the mail, the message is composed of one single line:
Description1 Description2
I have also changed "\n" for "\n\r", Environment.NewLine. But it didn't work.
Could you explain me what am I doing wrong?
You need to typecast it as below:
(DT_STR,2,1252)"\r\n"
For example...the below expression in Execute SQL task is dynamic SQL
"INSERT INTO [dbo].[OBJ_COUNT]([OBJ_NAME], [OBJ_COUNT]) VALUES ( " + "'EMPLOYEE_MASTER', " + (DT_STR, 10, 1252) (#[User::EMP_MAST_COUNT])+" );" + (DT_STR,2,1252)"\r\n" + "GO " + (DT_STR,2,1252)"\r\n" + "INSERT INTO [dbo].[OBJ_COUNT]([OBJ_NAME], [OBJ_COUNT]) VALUES ( " + "'DEPT_MASTER', " + (DT_STR, 10, 1252) (#[User::DEPT_MAST_COUNT])+" );" + (DT_STR,2,1252)"\r\n"+ "GO "
And will give output as below...
INSERT INTO [dbo].[OBJ_COUNT]([OBJ_NAME], [OBJ_COUNT]) VALUES ( 'EMPLOYEE_MASTER', 2514);
GO
INSERT INTO [dbo].[OBJ_COUNT]([OBJ_NAME], [OBJ_COUNT]) VALUES ( 'DEPT_MASTER', 2541);
GO
Try "\n\n" . This works but adds an extra line break. In most cases it is adequate.
This is a more explicite extension on my previous question.
From an button on an XPage I create a new database
targetDB = dir.createDatabase(fileName);
I then copy a bunch of stuff into the targetDB from the sourceDB. I then want to set the launch properties in the targetDB which is where the problem comes.
I know that I can get the iconNote = targetDB.getDocumentByID("FFFF0010") except there is no iconDoc in the target. Does anyone have a way to create this doc with the specific NoteID?
I tried copying the iconNote document from the sourceDB to the targetDB but that does not work. Changes the UNID and noteID. Can't find any database method to create an icon Note.
Found lots of stuff on how to change the settings in the iconNote, but nothing on how to create one if there is not one in the database.
Thanks to Jesse I took his code and changed it to SSJS and it works fine.
var dir:NotesDbDirectory = session.getDbDirectory("Development");
var newDB:NotesDatabase = dir.createDatabase("XPages/install/created.nsf");
var importer:NotesDxlImporter = session.createDxlImporter();
importer.setDesignImportOption(6);
var dxl:String = "<?xml version='1.0'?>\n" +
"<note default='true' class='icon'>\n" +
" <item name='$TITLE'>\n" +
" <text>Test Title</text>\n" +
" </item>\n" +
" <item name='$Flags'>\n" +
" <text>J7NZq?!</text>\n" +
" </item>\n" +
"</note>\n";
importer.importDxl(dxl, newDB);
var iconNote = newDB.getDocumentByID("FFFF0010");
iconNote.replaceItemValue("$DefaultXPage", "xpWFSDemo.xsp");
iconNote.replaceItemValue("$DefaultClientXPage", "xpWFSDemo.xsp");
iconNote.save();
dBar.info(iconNote.getItemValueString("$Flags"));
Something like this oughta do it:
DbDirectory dir = session.getDbDirectory(null);
Database newDB = dir.createDatabase("tests/created.nsf");
DxlImporter importer = session.createDxlImporter();
importer.setDesignImportOption(DxlImporter.DXLIMPORTOPTION_REPLACE_ELSE_CREATE);
String dxl = "<?xml version='1.0'?>\n" +
"<note default='true' class='icon'>\n" +
" <item name='$TITLE'>\n" +
" <text>Some DB Title</text>\n" +
" </item>\n" +
" <item name='$Flags'>\n" +
" <text>J7NZq?!</text>\n" +
" </item>\n" +
"</note>\n";
importer.importDxl(dxl, newDB);
That's with the two "open XPage" options set already - you could also include the two XPage name items the same way, and it may be a good idea to export the icon note from an existing DB (database.getDocumentByID("FFFF0010").generateXML()) and paste in the actual icon item as well, since this DXL will result in an icon-less database. Nonetheless, it seems to work in my testing as a basis.
And after that point, you'll be able to fetch the icon note using the usual "FFFF0010" pseudo-ID and replace item values the same way I mentioned before.
I'm trying to solve an issue I have when I'm trying to use OLE DB for reading Excel files.
I found that the problem is because there is a hash mark (#) in the sheet name.
Unfortunately, I can't rename the sheet.
So after some tries, I've succeeded to read a full sheet by adding quotation marks ('):
Before
Select * from [" + sheetName + "$];
After (working)
Select * from ['" + sheetName + "$'];
But then I got stuck when trying to read a range from the sheet with the OLE DB feature:
Select * from [" + sheetName + "$" + fromCell + ":" + toCell + "];
When I try to send this command, it's seems like the # is replaced by . and then it cannot find the sheet.
I've tried many combination and escape codes and didn't find any solution. How can I access this file?
Your final output should look like this
'MySheet$A1:B2'
So your select should be
var SheetName = "MySheet";
var fromCell = "A1";
var toCell = "B2";
var sql = "Select * from ['" + SheetName + "$" + fromCell + ":" + toCell + "']";
Console.WriteLine(sql);
// Output
// Select * from ['MySheet$A1:B2']
Also consider parametrising your sql for better readability and also preventing sql code injection. You can find a guide for how to do it at OleDbCommand.Parameters.
this code is in Textbox Change event.
dds.Tables["IncomeGenerator"].DefaultView.RowFilter = "' Income LIKE '" + txtSearch.Text + "' OR Expenses LIKE '" + txtSearch.Text + "' OR Date LIKE '" + txtSearch.Text + "' OR Balance LIKE '" + txtSearch.Text + "' OR Description LIKE '" + txtSearch.Text + "'";
when i run it, it gives a error saying " The expression contains an invalid string constant: '. "
can someone help me.
my Income, Expenses and Balance is Data Type Float and Date is Datetime. i hope it may help. can someone guide me with the mistake and help me
It's hard to tell for sure, but sometimes when I copy code from a web page or word processor, I inadvertently include a "book quote" (http://en.wikipedia.org/wiki/Quotation_mark_glyphs) that screws things up.
It looks like there may be some in the sample you posted. Try making sure all the quotes are the straight-up-and-down quotes, and not the begin-end "book quotes".
I am inserting a list item using sharepoint web services....
Here is my code:
item += #"<Field Name=""HyperLinkField"">" + this.SharePointSiteAddressLinks + #"/lists/" + this.ListName + #"/" + this.ID + "_" + this.MessageID + ", " + this.MessageID + ".ext</Field>";
the value of SharePointSiteAddressLinks is http://machineName
The list item gets inserted into the list, but the value of the hyperlink is set to http://localhost
Firstly - why does SharePoint take it apon itself to (incorrect) my links, 2ndly what can I do to turn it off?
Thank you
Restarted the server, everything worked fine....