- 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
52 Posted Topics
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] | |
Re: You can set ListBox's property 'Sorted' to 'true'. If you are using an array, make sure that sorting doesn't change combination of members. If you are using an array, there is a sort function. | |
Re: You can, like you pass values to for example SqlConnection constructor. | |
Re: You can use '[URL="http://www.asp.net/ajaxlibrary/act.ashx"]AJAX Control Toolkit[/URL]'. There is a SlideShow control. But if you want to use Javascript(which is the harder way) you could search Google. I suggest you to use AJAX Toolkit. | |
Re: You can use the following code. Code if for MS SQL Server, but if use for example Access database change "SqlConnection" to "OleDbConnection" or "OdbcConnection". [code] Private Function count() As Long SqlConnection connection = New SqlConnection("connectionString") SqlCommand command = New SqlCommand("SELECT COUNT(*) FROM tableName WHERE condition = ''",connection) SqlDataReader reader … | |
Re: Try with this code, I changed SQL query and parameter: [code] string connectionString = null; OleDbConnection connection; OleDbDataAdapter oledbAdapter = new OleDbDataAdapter(); string sql = null; connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + @"data source=Book.mdb"; connection = new OleDbConnection(connectionString); sql = "delete from Books where BookKey = @BookKey"; try { connection.Open(); oledbAdapter.DeleteCommand = … | |
I have function that returns string and that works fine but when I call that function from another procedure when it executes function I get a message: [B],,Conversion from 'result' to type 'Integer' is not valid,,[/B] ASP debugger says: [B],,Input string was not in a correct format. ,,[/B] I tried … | |
Re: I never use ToolTips that are definder in control properties. I always make a my tooltip, here's the code: [CODE] Private toolTipInformation As New ToolTip Private Sub show() toolTipInformation.Show("some text", window) End Sub Private Sub hide() toolTipInformation.Hide(window) End Sub [/CODE] [I]window[/I] Type: System.Windows.Forms.IWin32Window The Control to display the ToolTip for. | |
Re: Create a function that will check if user name exists, and if user name exists check if password is correct. | |
Re: ]You can use ASP validators. More information about them you can find on next link: [URL="http://www.w3schools.com/aspnet/aspnet_refvalidationcontrols.asp"]http://www.w3schools.com/aspnet/aspnet_refvalidationcontrols.asp[/URL] | |
Re: I don't like to use datasets and bindings. Try with next code, ORDER BY clause is if you want to sort data from table: [CODE] Dim connection As New SqlConnection(connectionString) Dim command As New SqlCommand("SELECT * FROM table ORDER BY collumn ASC", connection) Dim reader As SqlDataReader Try connection.Open() reader … | |
Re: Here is the code: [CODE] Dim result As String result = beginingString.Text.Remove(beginingString.Text.Length - 7, 7) [/CODE] | |
Re: If that is a SQL query, use next query: [CODE=sql] SELECT * FROM table WHERE date > 'date' AND date < 'date2' [/CODE] | |
I have some text with Cyrillic and Latin (š, đ, č, ć, ž). How can I store that data in MS SQL 2008. I tried to store word 'Palačinka' but instead of 'č' i get 'c'. | |
Re: Yes, is you want to sort data use next SQL statement: [CODE="sql"]SELECT collumnName FROM tableName[/CODE] | |
Re: Create a functions that will check if username exists (SELECT * FROM table WHERE USERNAME = '" & username & "'"). If reader.Read then return True else return False. It's same code for checking password (if password = reader("PASSWORD")).. | |
I have some data encrypted with MD5CryptoServiceProvider. I need code for decrpyting. | |
Re: Use next code: [CODE] Private Sub TextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox.KeyPress Dim ascii As Integer = Asc(e.KeyChar.ToString) ' Ascii code for comma is 46 If ascii = 46 Then e.KeyChar = "," End If End Sub [/CODE] | |
Re: I don't know how to recognise the character, but this code could help you: [CODE] Imports System.Drawing ... ' image is PictureBox control Dim bitmap As New Bitmap("LOCATION TO IMAGE") Dim rectangle As New Rectangle(New Point(image.Location.X, image.Location.Y), New Size(bitmap.Size.Width, bitmap.Size.Height)) image.DrawToBitmap(bitmap, rectangle) For i = 0 To bitmap.Size.Width Step +1 … | |
Re: This is for CheckedListBox: [CODE] For i = 0 To checkedListBoxName.Items.Count - 1 Step 1 checkedListBoxName.SetChecked(i, True) Next [/CODE] In ASP just write this code: [CODE] checkBox.Checked = True [/CODE] | |
I'm writting program in VB 2010, but I have a problem. I want to draw a temporary line on PictureBox control MouseMove event. That works fine but deleting of that line doesn't work. I tried to draw the white line on the same coordinates (PictureBox's background is white), but won't … |
The End.