|
arrays in C# are homogeneous, they can't hold different types, unless you declare them to hold a common type (in the extreme: object) which isn't a good idea. Create your own element type and keep it a one-dimensional array; in simple cases you might be well of by using a Dictionary (requires unique keys).
|
|
|
|
|
Hi all
I am using stringbuilder to create a printscreen and email. It is working well. Now I am trying to create a CSV file too. Sothat we can insert the data in SQL Database.
At the moment it does not create the csv yet. It is only printing on Screen and sending email. I want to add more code which will send me a CSV file when user fillouts the application.
Can you pls look at the code and help me where should i add new code to achive that?
Thanks
code looks like as below
using System;
using System.Web.Configuration;
using System.Net.Mail;
using System.Security.Cryptography.Pkcs;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.IO;
using System.Data;
using System.Data.SqlClient;
using System.Web.Services;
using System.Web.DataAccess;
using System.Web;
using System.Collections.Specialized;
using System.Net;
namespace HomeTrustELVForm
{
public partial class sendApplication : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.HttpMethod.ToUpper() == "POST")
{
if (Session["submitted"] == null)
{
Response.Expires = -1;
Response.AddHeader("Pragma", "no-cache");
Response.Cache.SetNoStore();
Response.Cache.SetNoServerCaching();
SmtpClient smtpClient = new SmtpClient(WebConfigurationManager.AppSettings["smtpServer"]);
MailAddress fromAddress = new MailAddress(WebConfigurationManager.AppSettings["appFromEmail"]);
MailAddress toAddress;
MailMessage objEmail;
X509Certificate2 cert;
String province = "";
String applicationType = "";
String refferedBy = "";
String phone = "";
String lookingFor = "";
String other = "";
String amount = "";
String multiple = "";
String coapplicant = "";
String consent = "";
String thirdParty = "";
String agree = "";
String principalResidence = "";
String sin = "";
String maritalStatus = "";
String firstName = "";
String initials = "";
String lastName = "";
String birthDay = "";
String maidenName = "";
String address = "";
String city = "";
String postalCode = "";
String homePhone = "";
String cellPhone = "";
String businessPhone = "";
String email = "";
String monthlyIncome = "";
String otherIncome = "";
String employer = "";
String employeeAddress = "";
String employerSuiteNum = "";
String employerCity = "";
String employerProvince = "";
String employerPostalCode = "";
String occupation = "";
String employer2Yrs = "";
String numYears = "";
String prevEmployer = "";
String propertyValue = "";
String propertyType = "";
String purchaseDate = "";
String origPurchasePrice = "";
String lender = "";
String mortgagePayment = "";
String mortgageBalance = "";
String maturityDate = "";
String secondMortgageLender = "";
String MonthlySecondMortgagePayment = "";
String secondMortgageBalance = "";
String secondMortgageMaturityDate = "";
String propertyTax = "";
String coPrincipalResidence = "";
String coSin = "";
String coMaritalStatus = "";
String coFirstName = "";
String coInitials = "";
String coLastname = "";
String coBirthDate = "";
String coMothersMaiden = "";
String coAddress = "";
String coCity = "";
String coProvince = "";
String coPostalCode = "";
String coHomePhone = "";
String coCellPhone = "";
String coBusinessPhone = "";
String coEmail = "";
String coMonthlyIncome = "";
String coOtherIncome = "";
String coCurrentEmployer = "";
String coEmployerAddress = "";
String coEmployerSuiteNum = "";
String coEmployerCity = "";
String coEmployerProv = "";
String coEmployerPostalCode = "";
String coOccupation = "";
String coEmployed2yrs = "";
String coNumYears = "";
String coPrevEmployer = "";
String source = "";
String medium = "";
String term = "";
String content = "";
String campaign = "";
String csegment = "";
String formFrom = "";
if (Request.Params["province"] != null) province = Request.Params["province"].Trim();
if (Request.Params["applicationType"] != null) applicationType = Request.Params["applicationType"].Trim();
if (Request.Params["refferedBy"] != null) refferedBy = Request.Params["refferedBy"].Trim();
if (Request.Params["phone"] != null) phone = Request.Params["phone"].Trim();
if (Request.Params["lookingFor"] != null) lookingFor = Request.Params["lookingFor"].Trim();
if (Request.Params["other"] != null) other = Request.Params["other"].Trim();
if (Request.Params["amount"] != null) amount = Request.Params["amount"].Trim();
if (Request.Params["multiple"] != null) multiple = Request.Params["multiple"].Trim();
if (Request.Params["coapplicant"] != null) coapplicant = Request.Params["coapplicant"].Trim();
if (Request.Params["consent"] != null) consent = Request.Params["consent"].Trim();
if (Request.Params["thirdParty"] != null) thirdParty = Request.Params["thirdParty"].Trim();
if (Request.Params["agree"] != null) agree = Request.Params["agree"].Trim();
if (Request.Params["principalResidence"] != null) principalResidence = Request.Params["principalResidence"].Trim();
if (Request.Params["sin"] != null) sin = Request.Params["sin"].Trim();
if (Request.Params["maritalStatus"] != null) maritalStatus = Request.Params["maritalStatus"].Trim();
if (Request.Params["firstName"] != null) firstName = Request.Params["firstName"].Trim();
if (Request.Params["initials"] != null) initials = Request.Params["initials"].Trim();
if (Request.Params["lastName"] != null) lastName = Request.Params["lastName"].Trim();
if (Request.Params["birthDay"] != null) birthDay = Request.Params["birthDay"].Trim();
if (Request.Params["maidenName"] != null) maidenName = Request.Params["maidenName"].Trim();
if (Request.Params["address"] != null) address = Request.Params["address"].Trim();
if (Request.Params["city"] != null) city = Request.Params["city"].Trim();
if (Request.Params["postalCode"] != null) postalCode = Request.Params["postalCode"].Trim();
if (Request.Params["homePhone"] != null) homePhone = Request.Params["homePhone"].Trim();
if (Request.Params["cellPhone"] != null) cellPhone = Request.Params["cellPhone"].Trim();
if (Request.Params["businessPhone"] != null) businessPhone = Request.Params["businessPhone"].Trim();
if (Request.Params["email"] != null) email = Request.Params["email"].Trim();
if (Request.Params["monthlyIncome"] != null) monthlyIncome = Request.Params["monthlyIncome"].Trim();
if (Request.Params["otherIncome"] != null) otherIncome = Request.Params["otherIncome"].Trim();
if (Request.Params["employer"] != null) employer = Request.Params["employer"].Trim();
if (Request.Params["employeeAddress"] != null) employeeAddress = Request.Params["employeeAddress"].Trim();
if (Request.Params["employerSuiteNum"] != null) employerSuiteNum = Request.Params["employerSuiteNum"].Trim();
if (Request.Params["employerCity"] != null) employerCity = Request.Params["employerCity"].Trim();
if (Request.Params["employerProvince"] != null) employerProvince = Request.Params["employerProvince"].Trim();
if (Request.Params["employerPostalCode"] != null) employerPostalCode = Request.Params["employerPostalCode"].Trim();
if (Request.Params["occupation"] != null) occupation = Request.Params["occupation"].Trim();
if (Request.Params["employer2Yrs"] != null) employer2Yrs = Request.Params["employer2Yrs"].Trim();
if (Request.Params["numYears"] != null) numYears = Request.Params["numYears"].Trim();
if (Request.Params["prevEmployer"] != null) prevEmployer = Request.Params["prevEmployer"].Trim();
if (Request.Params["propertyValue"] != null) propertyValue = Request.Params["propertyValue"].Trim();
if (Request.Params["propertyType"] != null) propertyType = Request.Params["propertyType"].Trim();
if (Request.Params["purchaseDate"] != null) purchaseDate = Request.Params["purchaseDate"].Trim();
if (Request.Params["origPurchasePrice"] != null) origPurchasePrice = Request.Params["origPurchasePrice"].Trim();
if (Request.Params["lender"] != null) lender = Request.Params["lender"].Trim();
if (Request.Params["mortgagePayment"] != null) mortgagePayment = Request.Params["mortgagePayment"].Trim();
if (Request.Params["mortgageBalance"] != null) mortgageBalance = Request.Params["mortgageBalance"].Trim();
if (Request.Params["maturityDate"] != null) maturityDate = Request.Params["maturityDate"].Trim();
if (Request.Params["secondMortgageLender"] != null) secondMortgageLender = Request.Params["secondMortgageLender"].Trim();
if (Request.Params["MonthlySecondMortgagePayment"] != null) MonthlySecondMortgagePayment = Request.Params["MonthlySecondMortgagePayment"].Trim();
if (Request.Params["secondMortgageBalance"] != null) secondMortgageBalance = Request.Params["secondMortgageBalance"].Trim();
if (Request.Params["secondMortgageMaturityDate"] != null) secondMortgageMaturityDate = Request.Params["secondMortgageMaturityDate"].Trim();
if (Request.Params["propertyTax"] != null) propertyTax = Request.Params["propertyTax"].Trim();
if (Request.Params["coPrincipalResidence"] != null) coPrincipalResidence = Request.Params["coPrincipalResidence"].Trim();
if (Request.Params["coSin"] != null) coSin = Request.Params["coSin"].Trim();
if (Request.Params["coMaritalStatus"] != null) coMaritalStatus = Request.Params["coMaritalStatus"].Trim();
if (Request.Params["coFirstName"] != null) coFirstName = Request.Params["coFirstName"].Trim();
if (Request.Params["coInitials"] != null) coInitials = Request.Params["coInitials"].Trim();
if (Request.Params["coLastname"] != null) coLastname = Request.Params["coLastname"].Trim();
if (Request.Params["coBirthDate"] != null) coBirthDate = Request.Params["coBirthDate"].Trim();
if (Request.Params["coMothersMaiden"] != null) coMothersMaiden = Request.Params["coMothersMaiden"].Trim();
if (Request.Params["coAddress"] != null) coAddress = Request.Params["coAddress"].Trim();
if (Request.Params["coCity"] != null) coCity = Request.Params["coCity"].Trim();
if (Request.Params["coProvince"] != null) coProvince = Request.Params["coProvince"].Trim();
if (Request.Params["coPostalCode"] != null) coPostalCode = Request.Params["coPostalCode"].Trim();
if (Request.Params["coHomePhone"] != null) coHomePhone = Request.Params["coHomePhone"].Trim();
if (Request.Params["coCellPhone"] != null) coCellPhone = Request.Params["coCellPhone"].Trim();
if (Request.Params["coBusinessPhone"] != null) coBusinessPhone = Request.Params["coBusinessPhone"].Trim();
if (Request.Params["coEmail"] != null) coEmail = Request.Params["coEmail"].Trim();
if (Request.Params["coMonthlyIncome"] != null) coMonthlyIncome = Request.Params["coMonthlyIncome"].Trim();
if (Request.Params["coOtherIncome"] != null) coOtherIncome = Request.Params["coOtherIncome"].Trim();
if (Request.Params["coCurrentEmployer"] != null) coCurrentEmployer = Request.Params["coCurrentEmployer"].Trim();
if (Request.Params["coEmployerAddress"] != null) coEmployerAddress = Request.Params["coEmployerAddress"].Trim();
if (Request.Params["coEmployerSuiteNum"] != null) coEmployerSuiteNum = Request.Params["coEmployerSuiteNum"].Trim();
if (Request.Params["coEmployerCity"] != null) coEmployerCity = Request.Params["coEmployerCity"].Trim();
if (Request.Params["coEmployerProv"] != null) coEmployerProv = Request.Params["coEmployerProv"].Trim();
if (Request.Params["coEmployerPostalCode"] != null) coEmployerPostalCode = Request.Params["coEmployerPostalCode"].Trim();
if (Request.Params["coOccupation"] != null) coOccupation = Request.Params["coOccupation"].Trim();
if (Request.Params["coEmployed2yrs"] != null) coEmployed2yrs = Request.Params["coEmployed2yrs"].Trim();
if (Request.Params["coNumYears"] != null) coNumYears = Request.Params["coNumYears"].Trim();
if (Request.Params["coPrevEmployer"] != null) coPrevEmployer = Request.Params["coPrevEmployer"].Trim();
if (Request.Params["source"] != null) source = Request.Params["source"].Trim();
if (Request.Params["medium"] != null) medium = Request.Params["medium"].Trim();
if (Request.Params["term"] != null) term = Request.Params["term"].Trim();
if (Request.Params["content"] != null) content = Request.Params["content"].Trim();
if (Request.Params["campaign"] != null) campaign = Request.Params["campaign"].Trim();
if (Request.Params["csegment"] != null) csegment = Request.Params["csegment"].Trim();
if (Request.Params["formFrom"] != null) formFrom = Request.Params["formFrom"].Trim();
<STRONG><U>'Printing on SCREEN</U></STRONG>
String txtMessage = ""
+ "------------------------------------------------------------------------<br/>"
+ "EQUITYLINE VISA CARD - ONLINE APPLICATION <br/>"
+ "------------------------------------------------------------------------<br/>"
+ "<br/>"
+ "PROVINCE: " + province + "<br/>"
+ "SOURCE: " + applicationType + "<br/>"
+ "REFERRED BY: " + refferedBy + "<br/>"
+ "PHONE: " + phone + "<br/>"
+ "PURPOSE: " + lookingFor + "<br/>"
+ "PURPOSE OTHER: " + other + "<br/>"
+ "CREDIT LIMIT: " + amount + "<br/>"
+ "DID MORE THAN ONE PERSON SIGN FOR THE PURCHASE OF THIS HOME: " + multiple + " <br/>"
+ "RELATIONSHIP TO CO-APPLICANT: " + coapplicant + "<br/>"
+ "CO-BORROWER DISCLOSURE: " + consent + "<br/>"
+ "NOT ACTING ON BEHALF OF 3RD PARTY: " + thirdParty + "<br/>"
+ "AGREED TO TERMS: " + agree + "<br/>"
+ "<br/>"
+ "------------------------------------------------------------------------<br/>"
+ "PLEASE TELL US ABOUT YOURSELF<br/>"
+ "------------------------------------------------------------------------<br/>"
+ "<br/>"
+ "APPLICANT'S PRINCIPAL RESIDENCE?: " + principalResidence + "<br/>"
+ "SIN: " + sin + "<br/>"
+ "MARITAL STATUS: " + maritalStatus + "<br/>"
+ "FIRST NAME: " + firstName + "<br/>"
+ "INITIAL: " + initials + "<br/>"
+ "LAST NAME: " + lastName + "<br/>"
+ "DATE OF BIRTH: " + birthDay + "<br/>"
+ "MOTHER'S MAIDEN NAME: " + maidenName + "<br/>"
+ "ADDRESS: " + address + "<br/>"
+ "CITY: " + city + "<br/>"
+ "PROVINCE: " + province + "<br/>"
+ "POSTAL CODE: " + postalCode + "<br/>"
+ "HOME PHONE: " + homePhone + "<br/>"
+ "MOBILE PHONE: " + cellPhone + "<br/>"
+ "BUSINESS PHONE: " + businessPhone + "<br/>"
+ "EMAIL: " + email + "<br/>"
+ "<br/>"
+ "------------------------------------------------------------------------<br/>"
+ "PLEASE TELL US ABOUT YOUR INCOME<br/>"
+ "------------------------------------------------------------------------<br/>"
+ "<br/>"
+ "MONTHLY INCOME: " + monthlyIncome + "<br/>"
+ "OTHER INCOME: " + otherIncome + "<br/>"
+ "CURRENT EMPLOYER: " + employer + "<br/>"
+ "EMPLOYER'S ADDRESS: " + employeeAddress + "<br/>"
+ "EMPLOYER'S SUITE: " + employerSuiteNum + "<br/>"
+ "EMPLOYER'S CITY: " + employerCity + "<br/>"
+ "EMPLOYER'S PROVINCE: " + employerProvince + "<br/>"
+ "EMPLOYER'S POSTAL CODE: " + employerPostalCode + "<br/>"
+ "OCCUPATION: " + occupation + "<br/>"
+ "MORE THAN TWO YEARS TO CURRENT EMPLOYER: " + employer2Yrs + "<br/>"
+ "YEARS/MONTHS THERE: " + numYears + "<br/>"
+ "PREVIOUS EMPLOYER: " + prevEmployer + "<br/>"
+ "<br/>"
+ "------------------------------------------------------------------------<br/>"
+ "PLEASE TELL US ABOUT YOUR HOME<br/>"
+ "------------------------------------------------------------------------<br/>"
+ "<br/>"
+ "PROPERTY VALUE: " + propertyValue + "<br/>"
+ "TYPE OF PROPERTY: " + propertyType + "<br/>"
+ "PURCHASE DATE: " + purchaseDate + "<br/>"
+ "WHAT DID YOU ORIGINALLY PAY FOR YOUR HOME: " + origPurchasePrice + "<br/>"
+ "FIRST MORTGAGE LENDER (INSTITUTION NAME AND PHONE NUMBER): " + lender + "<br/>"
+ "FIRST MORTGAGE MONTHLY PAYMENT: " + mortgagePayment + "<br/>"
+ "FIRST MORTGAGE BALANCE: " + mortgageBalance + "<br/>"
+ "MATURITY DATE: " + maturityDate + "<br/>"
+ "SECOND MORTGAGE LENDER, IF APPLICABLE (INSTITUTION NAME AND PHONE NUMBER): " + secondMortgageLender + "<br/>"
+ "SECOND MORTGAGE MONTHLY PAYMENT: " + MonthlySecondMortgagePayment + "<br/>"
+ "SECOND MORTGAGE BALANCE: " + secondMortgageBalance + "<br/>"
+ "SECOND MORTGAGE MATURITY DATE: " + secondMortgageMaturityDate + "<br/>"
+ "ANNUAL PROPERTY TAXES: " + propertyTax + "<br/>"
+ "<br/>"
+ "------------------------------------------------------------------------<br/>"
+ "CO-APPLICANT INFORMATION<br/>"
+ "------------------------------------------------------------------------<br/>"
+ "CO-APPLICANT'S PRINCIPAL RESIDENCE?: " + coPrincipalResidence + "<br/>"
+ "SIN: " + coSin + "<br/>"
+ "MARITAL STATUS: " + coMaritalStatus + "<br/>"
+ "FIRST NAME: " + coFirstName + "<br/>"
+ "INITIAL: " + coInitials + "<br/>"
+ "LAST NAME: " + coLastname + "<br/>"
+ "DATE OF BIRTH: " + coBirthDate + "<br/>"
+ "MOTHER'S MAIDEN NAME: " + coMothersMaiden + "<br/>"
+ "ADDRESS: " + coAddress + "<br/>"
+ "CITY: " + coCity + "<br/>"
+ "PROVINCE: " + coProvince + "<br/>"
+ "POSTAL CODE: " + coPostalCode + "<br/>"
+ "HOME PHONE: " + coHomePhone + "<br/>"
+ "MOBILE PHONE: " + coCellPhone + "<br/>"
+ "BUSINESS PHONE: " + coBusinessPhone + "<br/>"
+ "EMAIL: " + coEmail + "<br/>"
+ "<br/>"
+ "------------------------------------------------------------------------<br/>"
+ "CO-APPLICANT INCOME<br/>"
+ "------------------------------------------------------------------------<br/>"
+ "<br/>"
+ "MONTHLY INCOME: " + coMonthlyIncome + "<br/>"
+ "OTHER INCOME: " + coOtherIncome + "<br/>"
+ "CURRENT EMPLOYER: " + coCurrentEmployer + "<br/>"
+ "EMPLOYER'S ADDRESS: " + coEmployerAddress + "<br/>"
+ "EMPLOYER'S SUITE: " + coEmployerSuiteNum + "<br/>"
+ "EMPLOYER'S CITY: " + coEmployerCity + "<br/>"
+ "EMPLOYER'S PROVINCE: " + coEmployerProv + "<br/>"
+ "EMPLOYER'S POSTAL CODE: " + coEmployerPostalCode + "<br/>"
+ "OCCUPATION: " + coOccupation + "<br/>"
+ "MORE THAN TWO YEARS TO CURRENT EMPLOYER: " + coEmployed2yrs + "<br/>"
+ "YEARS/MONTHS THERE: " + coNumYears + "<br/>"
+ "PREVIOUS EMPLOYER: " + coPrevEmployer + "<br/>"
+ "<br/>";
String txtMessage2 = ""
+ "------------------------------------------------------------------------<br/>"
+ "ELV WEB INQUIRY - ADWORDS " + "<br/>"
+ "------------------------------------------------------------------------<br/>"
+ "<br/>"
+ "MARKETING CODE: " + "ADWORDS " + "- " + formFrom + "<br/>"
+ "SOURCE: " + source + "<br/>"
+ "KEYWORD: " + term + "<br/>"
+ "MEDIUM: " + medium + "<br/>"
+ "CAMPAIGN: " + campaign + "<br/>"
+ "AD CONTENT: " + content + "<br/>"
+ "csegment" + csegment + "<br/>"
+ "<br/>";
if (applicationType.ToLower().CompareTo("broker") == 0)
{
toAddress = new MailAddress(WebConfigurationManager.AppSettings["brokerAppToEmail"]);
cert = new X509Certificate2(Server.MapPath(WebConfigurationManager.AppSettings["brokerCertFile"]));
}
else
{
toAddress = new MailAddress(System.Configuration.ConfigurationManager.AppSettings["generalAppToEmail"]);
cert = new X509Certificate2(Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["generalCertFile"]));
}
objEmail = new MailMessage(fromAddress, toAddress);
objEmail.Subject = WebConfigurationManager.AppSettings["appSubject"];
objEmail.Priority = MailPriority.High;
objEmail.IsBodyHtml = true;
// Encrypt the email
StringBuilder sbMessage = new StringBuilder();
sbMessage.AppendLine("Content-Type: text/html; charset=\"iso-8859-1\"");
sbMessage.AppendLine("Content-Transfer-Encoding: 7bit");
sbMessage.AppendLine();
if (formFrom.CompareTo("DC") == 0)
{
sbMessage.Append(txtMessage + txtMessage2);
}
else if (formFrom.CompareTo("BFS") == 0)
{
sbMessage.Append(txtMessage + txtMessage2);
}
else
{
sbMessage.Append(txtMessage);
}
byte[] aMessage = Encoding.ASCII.GetBytes(sbMessage.ToString());
EnvelopedCms ECms = new EnvelopedCms(new ContentInfo(aMessage));
CmsRecipient Recipient = new CmsRecipient(SubjectIdentifierType.IssuerAndSerialNumber, cert);
ECms.Encrypt(Recipient);
byte[] aEncryptedMessage = ECms.Encode();
MemoryStream ms = new MemoryStream(aEncryptedMessage);
AlternateView av = new AlternateView(ms, "application/pkcs7-mime; smime-type=signed-data;name=smime.p7m");
objEmail.AlternateViews.Add(av);
smtpClient.ClientCertificates.Add(cert);
smtpClient.Send(objEmail);
Session["submitted"] = true;
try
{
DatabaseHelper.GetDataRow("proc_logApplication"
, new SqlParameter("@source", applicationType)
, new SqlParameter("@province", province)
, new SqlParameter("@city", city)
, new SqlParameter("@purpose", lookingFor.ToLower() == "other" ? other : lookingFor)
, new SqlParameter("@brokerName", refferedBy)
, new SqlParameter("@lastName", lastName)
);
}
catch (Exception exc)
{
Response.Write("Log failure: " + exc.ToString());
}
appform.Text = txtMessage;
if (consent.Substring(0, 2).ToLower().CompareTo("no") == 0)
{
statementCopy.Text = "You have chosen to receive <u>separate copies of Statements</u>.";
}
else
{
statementCopy.Text = "You have chosen to receive <u>only one copy of Statements</u>.";
}
ThankYou_Panel.Visible = true;
}
else
{
problemMessage.Text = "You have already submitted an application. If you wish to submit another application, please close your browser and revisit our site.";
Problem_Panel.Visible = true;
}
}
else
{
problemMessage.Text = "";
Problem_Panel.Visible = true;
}
}
}
}
|
|
|
|
|
Uh that's a big code
zjaffary wrote: Can you pls look at the code and help me where should i add new code to achive that?
As I presume you are trying to send cvs over mail. I do not know where it should go, but my suggestion is: »Collect all data and generate files before sending«
|
|
|
|
|
hey, I'm having a c# console application which deletes all the files in the server which are 5 days older. for the accessing the server shared path, we need give the user credentials, i don't know where and how to add the authentication part. please helplp me...
Thanks in advance.
vinoth
|
|
|
|
|
google "activedirectory"
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Hi all
I have a problem that became huge.
I want to make a backup from my database and if i attach my database to microsoft sql 2005 and use this connectionstring i can backup from my database correctly:
string connectionstring="Data Source=.;DataBase=mydatabase;Integrated Security=true"
but when i detach it from microsoft sql 2005 and add it to SQLEXPRESS and use SQLEXPRESS of visual studio by this connectionstring=@"Data Source=.\SQLEXPRESS;AttachDbFilename=" + Application.StartupPath + "\\Data\\mydatabase.mdf;" + "Integrated Security=True;User Instance=True";
but it didn't work and error delare that
"Could not locate entry in sysdatabases for database 'mydatabase'. No entry found with that name. Make sure that the name is entered correctly.
BACKUP DATABASE is terminating abnormally."
and because of some reason i want to use SQLEXPRESS.
what should i do?
note:This is my sql command for backup:
backup = string.Format(@"backup database mydatabase to disk='{0}'",addr);
backup.ExecuteNonQuery();
|
|
|
|
|
Anyone knows how to handle (read/write) the registry to search for a path, and how to send DOS commands for example to send SQL commands to attach and dettach a database from the SQL server?
|
|
|
|
|
Antonio JVS wrote:
example to send SQL commands to attach and dettach a database from the SQL server?
Quote Selected Text
Try the following:
SQL Express Command-Line Utility
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
Just need to send DOS commands like "sqlcmd -S ..." to register a database in the SQL and use it in the path it puts it, I'm in the begining of my application and see the best way to use the database.
|
|
|
|
|
For reading the registry, Windows XP and up provide the DOS-tool REG.EXE, with which you can read AND write registry-keys.
Nah... What's up, Doc?
CCC's solved : 1
If a bus station is where a bus stops, and a train station is where a train stops, why do I have a work station on my desk?
|
|
|
|
|
There are registry classes that you can use to interact with the registry. See this link.[^]
To issue DOS commands you can write a batch file on the fly and then execute it.
Here are some more relevant classes / enumerations for registry interaction
Registry Class Link[^]
RegistryHive Enumeration Link[^]
RegistryKey Class Link[^]
RegistryKeyPermissionCheck Enumeration Link[^]
RegistryValueKind Enumeration Link[^]
RegistryValueOptions Enumeration Link[^]
modified on Monday, December 14, 2009 9:37 AM
|
|
|
|
|
thaks it did help, just don't know how to create a batch file on the fly and execute it I'm new to C# and never used it on VB.
|
|
|
|
|
I suggest you get a begginners book and start from chapter one, this would fall under basic IO functions and then using the systems.diagnostics.process class to execute the batch file you created.
|
|
|
|
|
Hi my friends ........ I want to do term weighting by an approach called Composite measure(Tf*idf) ... it has its own formula ....
But what I want to do is to read files like(Word 2003,2007 pdf files etc.... ) then to take each word as an array .... I can read all files line by line by the following code
<br />
try<br />
{<br />
using (StreamReader sr = new StreamReader(textBox1.Text,Encoding.ASCII,true))
{<br />
String line;<br />
while ((line = sr.ReadLine()) != null)<br />
{<br />
richTextBox1.Text =richTextBox1.Text +Environment.NewLine+ line;<br />
<br />
}<br />
}<br />
}<br />
and to check the content of the file i tried to display it on a Richtextbox1 .... but it displays encrypted file .....
What I want to know is
1. How can I put each words(separated by Space and newline) in to array ... just to know each word (here displaying the content is not necessary)
2. How can I display the content of each file on Richtextbox1 ... but not in an encrypted form ....
Thanks for your help
|
|
|
|
|
The first thing you need to know is: Word and PDF files (as well as many others) are not necesarily line based text documents. Instead they are frequently binary files - which explains why they look encrypted.
The second thing you need to know is: Word and PDF files can be encrypted. So that may be why they lookm encrypted.
Google for "Word File Format" and "PDF File Format" - this will provide a starting point for you to gather the information you are going to need.
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
So how can i decrypt them? .... or can you tell me how to work on them please?
Just u can see my first question.
Thank you
|
|
|
|
|
Ummm...[^]
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
got noting ... just http://75.11.0.157/homenet/stupid.htm on z title bar .... What that supposed to mean?
|
|
|
|
|
Okay, how about this one[^]?
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
I couldn't open them either, using Chrome. It works in FF though
I are Troll
|
|
|
|
|
It's a picture and a caption - nothing special, and certainly nothing exotic. If Chrome can't open something that simple, I'd certainly entertain the idea of using one of the alternative browsers for my regular web-browsing pleasures...
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: It's a picture and a caption - nothing special, and certainly nothing exotic.
content="IE=EmulateIE7" ..and some css to position all that
John Simmons / outlaw programmer wrote: If Chrome can't open something that simple, I'd certainly entertain the idea of using one of the alternative browsers for my regular web-browsing pleasures...
You could also entertain the idea of installing multiple browsers. It's not a marriage, and I'm not going to commit to a single system
I are Troll
|
|
|
|
|
Well, IE 6 and 8 show it just fine without any special compatibility tags.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Gets my five!
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
Decrypt: First, find out the password...
Because they aren't stored as straight text, you can't just read them and identify the words. The files contain heaps of other stuff: font, size, colour, location, lines, boxes, italics, bold, pictures, spreadsheets, etc. etc. etc. If all you are interested in is the text of the document and doing some textual analysis, then the best thing you can do is to throw away as much of the formatting as possible, and save the file as a straight .TXT file from Word and/or PDF. You can then read the whole thing in, and use string.Split (with space and reasonable puncuation) to break it into words.
All those who believe in psycho kinesis, raise my hand.
|
|
|
|