- Strength to Increase Rep
- +5
- Strength to Decrease Rep
- -1
- Upvotes Received
- 9
- Posts with Upvotes
- 9
- Upvoting Members
- 4
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
Re: [code] public void connect() { SqlConnection connection = new SqlConnection("connectionString"); try { connection.Open(); } catch { // Show error } finally { connection.Close(); } } [/code] Don't forget to add [code]System.Data.SqlClient[/code] reference to project. | |
Re: That maybe happens because page and master are not in the same folder. To solve this case register script file on page load. | |
Re: Pass values by the class constructor: Form that you want to open: [code] ... string arg; public className(argumentThatYouWantToPass) { InitializeComponents; arg = argumentThatYouWantToPass; } ... [/code] Form that will open another form: [code] public void openForm() { Form2 form = new Form2(argument); form.Show(); } [/code] | |
| |
Re: I don't think that is possible on server or client side. It can be done if you modify web browser. | |
Re: If you use SQL Server Authentication (which is true this case) you must set Integrated Security parameter to false. This should work: [code] return new SqlConnection(@"Data Source=68.71.135.2,2121;Initial Catalog=DBTest;Integrated Security=False;User ID=myId;Password=mypass;"); [/code] | |
Re: - Insert statement should be: [code] cmdSave.CommandText = "insert into tblMember(Std_ID,Last_N,First_N,Mid_N,Level,Section) values (@Std_ID,@Last_N,@First_N,@Mid_N,@Level,@Section)"; [/code] - You don't have to write explicity which data type is parameter (in some cases you must - very rare), and when you add parameter to SqlCommand there should be no '@' sign. [code] cmdSave.Parameters.Add(new SqlParameter("Std_ID", … | |
Re: You can limit textbox's maximum length by settings its attribute length/max length to 4 in the Properties panel. | |
I'm creating multimedia player for some compatition, but I'm facing with problem with measuring audio output which is going to speaker/s. How can I measure it without some compicated code like CoreAudioApi which I found on CodeProject forum. I tried it to use but I'm getting some COM casting error. | |
Re: Your code in vulnerabile with SQL injection. Always use parametarised queries: [code] public void checkUsername() { string qry = "SELECT Password FROM Tablename WHERE User=@username"; using (SqlConnection conn = new SqlConnection("YourConnectionString")) { try { conn.Open(); SqlCommand cmd = new SqlCommand(qry, conn); cmd.Parameters.Add(new SqlParameter("username", userName.Text)); SqlDataReader reader; reader = cmd.ExecuteReader(); if … | |
Re: Date that you want to insert in SQL Server database must be in format [b]MM/dd/yyyy[/b], and time must be in format [b]hh:mm:ss[/b]. Don't forget to set data type of collumn in database to [i]datetime[/i]. [code] string dateAndTime = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss"); ... command.ExecuteNonQuery(); [/code] | |
Re: 1. All variables declared in class are by default private. If you want that they can be visible to any method, try putting keyword public before data type. [code] public int variable1; [/code] 2. If you have location map, I think that there must be X and Y cooridnate? | |
Re: 1. UserRow reference is not added to a project. If you created that class, add reference, or if that class is in .NET Framework Base Class Library add reference to it with 'using' directive. 2. After createing a new instance of any class in C# there must be () or … | |
Re: 1. Generate a random number with [B]Random[/B] class. There must be an option in StreamReader/TextReader to get block from the specific location. 2. If that text file is in the same folder where application is, use just file's name eg. [code] StreamReader reader = new StreamReader("file.txt"); [/code] | |
Re: When form is submitted, SelectedIndex property is lost, you must save it with query string, session or something, and then you can use it without error. [code] Response.Redirect("page.aspx?index=" + dropDownList1.SelectedIndex); [/code] or [code] // Saving the selected index value Session["index"] = dropDownList1.SelectedIndex; // Getting selected index value string index = … | |
Re: [URL="http://msdn.microsoft.com/en-us/library/w4atty68.aspx"]http://msdn.microsoft.com/en-us/library/w4atty68.aspx[/URL] | |
Re: I created it today with CSS and javascript. Use two events - onmouseover, onmouseout. When event is triggered menu, there should be a javascript function that will show/hide submenu. [code=jscript] function show() { // To hide submenu change block to none document.getElementById("element").setAttribute("display", "block"); } [/code] | |
Re: To download you can just use Response.Redirect() function. [code] Response.Redirect("~/file.extension"); [/code] | |
Re: - I think that converting from ASP page to HTML can be done only when application is runed from server. - I suggest you to use some other element, try replacing 'iframe' with 'div', 'table' or other element that could be replace for 'iframe'. | |
Re: I think he wanted to know how to create menu. Not DropDownList control. Check following links for DropDownList menu: - [URL="http://cssmenumaker.com/drop_down_css_menu.php"]http://cssmenumaker.com/drop_down_css_menu.php[/URL] - [URL="http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=css+menu"]http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=css+menu[/URL] | |
Re: Global variable is variable that is visible to all methods in class. In VB they can be visible to all classes. [URL="http://en.wikipedia.org/wiki/Global_variable"]http://en.wikipedia.org/wiki/Global_variable[/URL] | |
Re: Try with this: [code] public System.Drawing.Image LoadImagePiece(string imagePath, Rectangle desiredPortion) { using (Image img = Image.FromFile(path)) { Bitmap result = new Bitmap(desiredPortion.Width, desiredPortion.Height, PixelFormat.Format24bppRgb); using (Graphics g = Graphics.FromImage((Image)result)) { g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; g.DrawImage(img, 0, 0, desiredPortion, GraphicsUnit.Pixel); } return result; … | |
Re: [code] private string convertDate(string dateToConvert) { DateTime date = Convert.ToDateTime(dateToConvert); return date.ToString("MM/dd/yyyy"); } [/code] | |
Re: Every time you update database with some data, send new e-mail: [code] try { MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtpServer"); mail.From = new MailAddress(""); mail.To.Add(""); mail.Subject = ""; mail.Body = ""; SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential("username", "password"); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); } catch (Exception … | |
Re: I would use following query to check if there is a user with same username exists. Check can be performed with 'if' statement and reader.Read() function. [code=sql]SELECT * FROM table WHERE username = @username[/code] MitjaBonca is right. | |
Re: You don't have to use ' character in T-SQL query except in data that you want to insert into table. [code=sql]INSERT INTO table (column1, column2, column3, ...) VALUES('', '', '', ...)[/code] | |
Re: You use default creditians, and you specified to use your creditians. That could be why the error is generated. Change following section of your code to: [code] protected void btnSend_Click(object sender, EventArgs e) { try { MailMessage mm = new MailMessage(); SmtpClient smtp = new SmtpClient(); mm.From = new MailAddress(txtFrom.Text); … | |
I'm creating some barcode generator, and I want to save generated barcode to database, but I have a problem when I want to get bytes from PictureBox Image. It says that Image property is null. That's hapening because barcode is drawn on the PictureBox(not in Image property). I think that … | |
Re: You need to specify the download location. That means instead: "C:\\Users\\Skull\\Desktop" you need to put "C:\\Users\\Skull\\Desktop\\Lsusb.tar.bz2". Here's the documentation: [url]http://msdn.microsoft.com/en-us/library/ez801hhe(v=VS.100).aspx[/url] |