Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I have always created user accounts on the sql-server. When the connection is made the connection string needs to include the user name and password. You can write C# program to create users in the sql-server but you program will ultimately have to send the CREATE USER sql string.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Preferred editor should depend on your preferred coding environment. On MS-Windows I prefer Visual Studio for C, C++, C# amd VB.NET. For others like HTML I just use Notepad. In *nix I use Code::Blocks or vi.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The program crashes because the pointer to class Test points to nowhere. You have to set it to a valid memory location before it can be used

int main()
{
    // Pointer to class
    Test *t = new Test; // <<< allocate memory for the pointer

What does it help to make a class object as a pointer?

In your simple program it doesn't help at all. What you are trying to do is learn how to use pointers, which becomes very useful in more complex programs.

*k = t->GetMax(10, 9);

That isn't going to work either for the same reason *T didn't work, no memory allocated to the pointer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

i am to try the gets()

Don't bother with that. use getline() as nullptr suggested.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

your link is not valid. But here is how to do it

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

lines 3 and 4 are wrong, it's '\0', not '/0'

you have to clear the stringstream before re-using it. Put this after line 12

ss.clear();
ss.seekp(0); // for outputs: seek put ptr to start
ss.seekg(0); // for inputs: seek get ptr to start
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yea! I see the dot now. I was expecting it to be under the avatar (where most web sites have it) but it works ok next to the posting time.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes, the online indicator respects the invisible option.

Shouldn't I be able to see the dots of other members did not turn invisibility off?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I didn't change anything like that. In fact I made no code changes at all to Form2. Here's the application declarations, all code generated by vb.net

    Private Sub InitializeComponent()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.SuspendLayout()
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(112, 94)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(39, 13)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "Label1"
        '
        'Form2
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(284, 262)
        Me.Controls.Add(Me.Label1)
        Me.Name = "Form2"
        Me.Text = "Form2"
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Are all purple dots invisible when Invisibility mode is on? I don't see any dots of any color.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

<wrong thread>

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The program you posted doesn't give me any exceptions (vs 2012), works as expected. As long as lockThis is declared readonly there should be no problem.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No. The file is closed when leaving the lock block of code.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

buttons don't have a boolean property that works like that. You might have to create your own boolean variables that are toggled on and off each time you click the button. Something like this example

Public Class Form1
    Dim button1_clicked As Boolean = False
    Dim button2_clicked As Boolean = False

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If button1_clicked = False Then
            button1_clicked = True
            TextBox1.Text += "Button1 is on" & vbCrLf
        Else
            button1_clicked = False
            TextBox1.Text += "Button1 is off" & vbCrLf
        End If
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        If button2_clicked = False Then
            button2_clicked = True
            TextBox1.Text += "Button2 is on" & vbCrLf
        Else
            button2_clicked = False
            TextBox1.Text += "Button2 is off" & vbCrLf
        End If

    End Sub
End Class
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That Microsoft article is incorrect. The program causes an exception if LockThis is anything other than static.

There is not guarentee that threads will execute in consecutive order, as you can see from the output in that text file. You should not expect to see alternating lines of thread t1 and t2 in the file unless you tell the thread to release cpu time back to the MS-Windows task scheduler. I assume this will probably not be that big a problem for you in a complete program where each thread also has other tasks to do.

Is your intent to creat a program that produces a log file? If it is, there may be alternate ways to accomplish that.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

should be me.controlbox = false, or when in design view set the ControlBox property to false.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

According to this article lockThis needs to be a static object.
static readonly System.Object lockThis = new System.Object();

The above change made your program work for me.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I've written a short tutorial how to get started writing sql database applications with C#. The totorial is in PDF format so that you can download it and read at your leasure. It assumes you are using MS-Windows and Visual Studio 2012. If you are using an earlier version of VS then screenshots may be slightly different that those shown in the tutorial. I also assume you already know C# language and can read the code/understand the code. Below is the code. I posted it here without comment because it's explained in the tutorial. The same code is in the tutorial but MS-Word 2010 only inserted a screen shot of it, making it somewhat difficult to read.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MyDVDCollection1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dvd_collectionDataSet.movies' table. You can move, or remove it, as needed.
//            this.moviesTableAdapter.Fill(this.dvd_collectionDataSet.movies);

        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            this.moviesBindingSource.EndEdit();
            this.moviesTableAdapter.Update(this.dvd_collectionDataSet.movies);
        }

        private void btnRefresh_Click(object sender, EventArgs e)
        {
            this.moviesTableAdapter.Fill(this.dvd_collectionDataSet.movies);

        }

        private void btnClear_Click(object sender, EventArgs e)
        {
            // Remove all selected rows from the Grid
            Int32 selectedRowCount =
                dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected);
            if (selectedRowCount > 0)
            {

                for (int i = 0; i < selectedRowCount; i++)
                {
                    dataGridView1.Rows.RemoveAt(dataGridView1.SelectedRows[i].Index);
                }
            }
        }
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

but free speech and all that

"free speech" is not an issue here, no one has the right to free speech on privately owned forums. The right to free speech is only a government issue, not private issue. If Dani said you will be banned for posting "IMO" then she ccan do that. The only reason foul language is banned is because Dani said so. I've been on other sites where it's perfectly acceptable language.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

how are you displaying form2? I do it with a button click in form1. So after creating an instance of form2 you just assign the text from form1.textox1.text to form2.label1.text

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim fm2 As Form2 = New Form2
        fm2.label1.Text = Me.textbox1.Text
        fm2.ShowDialog()
    End Sub
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can't mix managed and unmanaged code like that. The program you wrote is NOT standard c++, but is CLI/C++ which is somewhat different. CLI/C++ is a .NET language, similir to C# and VB.NET. Fortunately, CLI/C++ has managed version of many standard c++ containers located in the cliext folder. You can not use std::string with any of the containers in cliext, so there is no point including <string> header file.

#include <cliext/vector>
using namespace cliext;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You might put the connection string in an app.config file so that it can be customized for each computer on which the program is running without recompiling the program.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Problem reesolved, I had to download a new driver.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It's all handled by the operating system. The os contains a task scheduler whose job is to give cpu time to the various processes that are running. Here is an article that will interest you.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It seems to be ok with IE9

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No such thing as "shared" namespaces. A namespace is a namespace, it doesn't have "shared" attribute. A namespace is just something that better organizes the data, classes, structures and code. It's main purpose it to avoid name clashes. Without namespaces all names must be unique throughout the program (with a few exceptions). If I declared a variable named int x; in one *.cpp file and declared a variable with the same name in another *.cpp file the liker would most likely complain that it found two variables with the same name. But if I put each of those variables in different namespaces then the linker would have no problem because each would actually be different variables.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No, I'm using VS2012 Pro

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

have you tried to google "multi language programming"? Here seems to be a good article about that topic.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Look at the sql statements in this tutorial

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Untitled40 I'm trying to figure out how to add a new connection to MySQL running on a different computer on my network. When I click Project --> New Data Source a list of drivers appears, but none of them are MySQL (see thumbnail) which I have previously installed. I'm using 64-bit Windows 7. The MySQL database is on a computer running 64-bit Windows 8.

I found a tutorial that works (see code below) with a console program, but I want to use Dataset

Imports System.Data
Imports MySql.Data.MySqlClient

Module Module1
    Private con As New MySqlConnection
    Private cmd As New MySqlCommand
    Private reader As MySqlDataReader

    Private _host As String = "<ip address here>" ' Connect to localhost database
    Private _user As String = "<user name here>" 'Enter your username, default is root
    Private _pass As String = "<password here>" 'Enter your password

    Sub Main()
        Dim oConn As String
        oConn = "Server=""" + _host + """;User Id=""" + _user + """;Password=""" + _pass + """;"
        con = New MySqlConnection(oConn)
        Try
            con.Open()
            'Check if the connection is open
            If con.State = ConnectionState.Open Then
                con.ChangeDatabase("dvd_collection") 'Use the MYSQL database for this example
                Console.WriteLine("Connection Open")
                Dim Sql As String = "SELECT title,date_format(release_date,""%Y-%m-%d"") as Date FROM movies"
                cmd = New MySqlCommand(Sql, con)
                reader = cmd.ExecuteReader()


                'Loop through all the users
                While reader.Read()
                    Console.WriteLine("Title: " & reader.GetString(0)) 'Get the host
                    Console.WriteLine("Release Date: " & reader.GetString(1)) 'Get the username
                End While

            End If
        Catch ex As Exception
            Console.WriteLine(ex.Message) ' Display any errors.
        End Try …
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what doesn't it do that you want it to do? Or what does it do that you don't want it to do?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

pulled pork and diet pepsi

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

but you didn't post what you tried. No one can help you any more if you dont' or won't post what you did.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

There have been several suggestions posted in this thread. Post the code you have tried instead of just crying "I can't!"

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is a short tutorial

Example of adding a combobox control

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            ComboBox comboBox1 = new ComboBox();
            comboBox1.Items.Add("Item 1");
            comboBox1.Items.Add("Item 2");
            comboBox1.Items.Add("Item 3");
            comboBox1.Location = new Point(100, 100);
            comboBox1.Width = 200;
            // Add the combo box to a parent container in the visual tree.
            this.Controls.Add(comboBox1);

        }
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The concept is very similar to fstream's open() and close() methods, except ADO uses COM or sockets as underlying file/data transfer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

They can also be created using stored procedures, assuming you have the permissions to do that.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If I'm not mistaken, the form won't fire the keydown or keypress events unless it has focus,

I tested with with vb.net 2012, the code I posted works when a textbox has focus. My guess is that first the Form event handler gets called, then the TextBox.

I've tried your code but it doesn't work.

Probably because you forgot to set KeyPeview property to TRUE as I mentioned in my previous post.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

wish granted, but a car hit and killed you on the freeway.

I wish to go on holiday in Austrilia.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Then try one of the other flags. Keep trying until you get the results you want.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 95 needs to have std::ate in the second parameter to tell fstream not to erase existing file contents. Note for ofstream ios::out is unnecessary because that's the default. See flags here

ofstream inOutProd("prod.dat", ios::ate );

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you are only 8 years too late with your post, and that is a horribly complex program for just subtracting two dates.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The database admin sent an email to everyone about a new antivirus program, the email stated something to the effect that if you want viruses then get this program. My reply was "I don't want it if it contains a virus". I meant to send it only to the db admin, but instead clicked Send All and it went out to about 200 people! Needless-to-say I got a few emails about that blunder :) The db admin wasn't amused.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can do this from the Form level instead of a control like below. In the Form's properties you have to set KeyPreview to True for this to work

Public Class Form1

    Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles MyBase.KeyDown
        If e.KeyCode = Keys.A Then
            Button1.PerformClick()
        ElseIf e.KeyCode = Keys.B Then
            Button2.PerformClick()
        End If
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        MsgBox("Hello from Button1")
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        MsgBox("Hello from Button2")

    End Sub
End Class
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Could be wrong, but my testing with vb.NET 2012 indicates MSSql Express can only run locally. I think you would need MSSQL Server (not the express version) to do what you want.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Post the code you have written and ask question(s) about what you don't understand.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I did that once too, emberrising.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Just as I suspected. You can't use = to assign a string, you must copy it. Note you don't need dupstr() function. Since salary is an int you need to convert from char* to int.

int i = 0;
while( fgets(line,sizeof(line),sourcefile))
{
     strcpy(Array[i].name, strtok(line,";"));
     strcpy(Array[i].job, strtok(NULL,";"));
     Array[i].salary = atoi(strtok(NULL,";"));
     ++i;
}