Click here to Skip to main content
15,900,254 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: WSO CCC 2019-06-10 - Winner Pin
Michael Martin10-Jun-19 4:41
professionalMichael Martin10-Jun-19 4:41 
GeneralA spontaneous composition PinPopular
Ravi Bhavnani9-Jun-19 14:58
professionalRavi Bhavnani9-Jun-19 14:58 
GeneralRe: A spontaneous composition Pin
GKP19929-Jun-19 19:29
professionalGKP19929-Jun-19 19:29 
GeneralRe: A spontaneous composition Pin
Super Lloyd9-Jun-19 20:38
Super Lloyd9-Jun-19 20:38 
GeneralRe: A spontaneous composition Pin
Ron Anders10-Jun-19 3:10
Ron Anders10-Jun-19 3:10 
GeneralRe: A spontaneous composition Pin
Mike Hankey10-Jun-19 4:12
mveMike Hankey10-Jun-19 4:12 
GeneralRe: A spontaneous composition Pin
Roger Wright11-Jun-19 17:03
professionalRoger Wright11-Jun-19 17:03 
QuestionC# insert into Pin
SuperJWP9-Jun-19 8:47
SuperJWP9-Jun-19 8:47 
i am trying to add data into my MSSQL table with the following C# code, however when i query the SQL table i receive numeric value in my columns, see my code.When i debug the code i receive no errors , code is successfull

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;
using System.Data.SqlClient;
using System.Configuration;

namespace InformationTechnologyInventoryStock
{
    public partial class Workstations : Form
    {
        private int n;

        public Workstations()
        {
            InitializeComponent();
        }

        private void Workstations_Load(object sender, EventArgs e)

        {
       
        }
        SqlConnection con = new SqlConnection(@"Data Source=SH-JASONK\DEV;Initial Catalog=StockInventory;Integrated Security=True");
        private void button1_Click(object sender, EventArgs e)
        {
            con.Open();
            SqlCommand cmd = new SqlCommand("INSERT INTO Workstations (Emp_Name, Emp_Surname, Department, Company, Hostname, Wkst_Status, Make, Model, SerialNumber, ProductNumber, PurchaseDate, ExpiryDate, Memory, Processor, HDD, OS, MSOffice) VALUES (@Emp_Name, @Emp_Surname, @Department, @Company, @Hostname, @Wkst_Status, @Make, @Model, @SerialNumber, @ProductNumber, @PurchaseDate, @ExpiryDate, @Memory, @Processor, @HDD, @OS, @MSOffice)");
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
          

            cmd.Parameters.AddWithValue("@Emp_Name", SqlDbType.VarChar);
            cmd.Parameters.AddWithValue("@Emp_Surname", SqlDbType.VarChar);
            cmd.Parameters.AddWithValue("@Department", SqlDbType.VarChar);
            cmd.Parameters.AddWithValue("@Company", SqlDbType.VarChar);
            cmd.Parameters.AddWithValue("@Hostname", SqlDbType.NVarChar);
            cmd.Parameters.AddWithValue("@Wkst_Status", SqlDbType.VarChar);
            cmd.Parameters.AddWithValue("@Make", SqlDbType.VarChar);
            cmd.Parameters.AddWithValue("@Model", SqlDbType.NVarChar);
            cmd.Parameters.AddWithValue("@SerialNumber", SqlDbType.NVarChar);
            cmd.Parameters.AddWithValue("@ProductNumber", SqlDbType.NVarChar);
            cmd.Parameters.AddWithValue("@PurchaseDate", dateTimePicker1.Value.Date);
            cmd.Parameters.AddWithValue("@ExpiryDate", dateTimePicker2.Value.Date);
            cmd.Parameters.AddWithValue("@Memory", SqlDbType.NVarChar);
            cmd.Parameters.AddWithValue("@Processor", SqlDbType.NVarChar);
            cmd.Parameters.AddWithValue("@HDD", SqlDbType.NVarChar);
            cmd.Parameters.AddWithValue("@OS", SqlDbType.NVarChar);
            cmd.Parameters.AddWithValue("@MSOffice", SqlDbType.NVarChar);

            cmd.Connection = con;
            DataTable dt = new DataTable();
          
            sda.Fill(dt);
            cmd.ExecuteNonQuery();
            con.Close();
            MessageBox.Show("INSERTED SUCCESSFULLY");

        }



    }
        }


I am new to c# and would like someone to assist where i am going wrong and why i am not seeing my input data
GeneralRe: C# insert into Pin
PIEBALDconsult9-Jun-19 8:56
mvePIEBALDconsult9-Jun-19 8:56 
GeneralRe: C# insert into Pin
Marc Clifton10-Jun-19 2:33
mvaMarc Clifton10-Jun-19 2:33 
AnswerRe: C# insert into Pin
OriginalGriff9-Jun-19 9:25
mveOriginalGriff9-Jun-19 9:25 
AnswerRe: C# insert into Pin
ZurdoDev10-Jun-19 1:54
professionalZurdoDev10-Jun-19 1:54 
AnswerRe: C# insert into Pin
Slow Eddie11-Jun-19 5:10
professionalSlow Eddie11-Jun-19 5:10 
GeneralThe world on Sunday PinPopular
OriginalGriff9-Jun-19 5:57
mveOriginalGriff9-Jun-19 5:57 
GeneralRe: The world on Sunday Pin
Dean Roddey9-Jun-19 6:06
Dean Roddey9-Jun-19 6:06 
GeneralRe: The world on Sunday Pin
Mike Hankey9-Jun-19 7:00
mveMike Hankey9-Jun-19 7:00 
GeneralRe: The world on Sunday Pin
RickZeeland9-Jun-19 10:41
mveRickZeeland9-Jun-19 10:41 
GeneralRe: The world on Sunday Pin
Mike Hankey9-Jun-19 11:05
mveMike Hankey9-Jun-19 11:05 
AnswerRe: The world on Sunday Pin
lopatir9-Jun-19 7:33
lopatir9-Jun-19 7:33 
GeneralRe: The world on Sunday Pin
PeejayAdams9-Jun-19 23:53
PeejayAdams9-Jun-19 23:53 
AnswerRe: The world on Sunday Pin
ZurdoDev10-Jun-19 1:56
professionalZurdoDev10-Jun-19 1:56 
GeneralRe: The world on Sunday Pin
OriginalGriff10-Jun-19 2:34
mveOriginalGriff10-Jun-19 2:34 
GeneralRe: The world on Sunday Pin
ZurdoDev10-Jun-19 2:38
professionalZurdoDev10-Jun-19 2:38 
NewsXCOM: ENEMY UNKNOWN Pin
RickZeeland9-Jun-19 1:43
mveRickZeeland9-Jun-19 1:43 
GeneralRe: XCOM: ENEMY UNKNOWN Pin
charlieg9-Jun-19 10:17
charlieg9-Jun-19 10:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Straw Poll

Were you affected by the geomagnetic storms this past weekend?
Communication disruptions, electrified pipes, random unexplained blue-screens in Windows - the list of effects is terrifying.
  Results   483 votes