Click here to Skip to main content
15,901,122 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# Sql calling function - SELECT from two diffrent Sql folders Pin
Member 1464122431-Oct-19 22:51
Member 1464122431-Oct-19 22:51 
GeneralRe: C# Sql calling function - SELECT from two diffrent Sql folders Pin
OriginalGriff31-Oct-19 23:09
mveOriginalGriff31-Oct-19 23:09 
GeneralRe: C# Sql calling function - SELECT from two diffrent Sql folders Pin
Member 1464122431-Oct-19 23:14
Member 1464122431-Oct-19 23:14 
GeneralRe: C# Sql calling function - SELECT from two diffrent Sql folders Pin
OriginalGriff31-Oct-19 23:26
mveOriginalGriff31-Oct-19 23:26 
GeneralRe: C# Sql calling function - SELECT from two diffrent Sql folders Pin
Member 146412241-Nov-19 0:11
Member 146412241-Nov-19 0:11 
QuestionALPHA CHANNEL Pin
Member 1463438031-Oct-19 2:05
Member 1463438031-Oct-19 2:05 
AnswerRe: ALPHA CHANNEL Pin
Richard MacCutchan31-Oct-19 4:05
mveRichard MacCutchan31-Oct-19 4:05 
QuestionArgument 1: cannot convert from 'object' to 'string' Pin
User 1460643731-Oct-19 0:53
User 1460643731-Oct-19 0:53 
I have a problem. I'm trying to get just a company Name from the database and place them in the listbox and when selecting the name the program would show the org. number and notes in text boxes next to the listbox (and later to be able to delete, add and edit companies). I'm already stuck in showing data in the listbox. I'm getting this error "listBoxOrg.Items.Add((tempRow["Name"]));" -->"Argument 1: cannot convert from 'object' to 'string'. I'm pretty new to this so I don't know how to solve it. Is the code all crap or what am I missing? Been wondering also if my database adress is correctly done.. Anyone that can help me out?

This is my code so far:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading.Tasks;



namespace Scenario1
{
    public partial class companies1 : System.Web.UI.Page
    {
        public static ArrayList Files = new ArrayList();
        protected void Page_Load(object sender, EventArgs e)
        {
            string str = "Data Source=BIG-BAD-WOLF-CO\\SQLEXPRESS;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";

            SqlConnection con = new SqlConnection(str);
            string com = "select Name from Companies";
            SqlDataAdapter adpt = new SqlDataAdapter(com, con);
            DataSet myDataSet = new DataSet();
            adpt.Fill(myDataSet, "Companies");
            DataTable myDataTable = myDataSet.Tables[0];
            
            DataRow tempRow = null;

            foreach (DataRow tempRow_Variable in myDataTable.Rows)
            {
                tempRow = tempRow_Variable;
                
                listBoxOrg.Items.Add((tempRow["Name"]));
            }

        }
     }
}


modified 1-Dec-20 21:01pm.

AnswerRe: Argument 1: cannot convert from 'object' to 'string' Pin
OriginalGriff31-Oct-19 1:19
mveOriginalGriff31-Oct-19 1:19 
GeneralRe: Argument 1: cannot convert from 'object' to 'string' Pin
User 1460643731-Oct-19 1:35
User 1460643731-Oct-19 1:35 
GeneralRe: Argument 1: cannot convert from 'object' to 'string' Pin
OriginalGriff31-Oct-19 1:47
mveOriginalGriff31-Oct-19 1:47 
GeneralRe: Argument 1: cannot convert from 'object' to 'string' Pin
User 1460643731-Oct-19 1:59
User 1460643731-Oct-19 1:59 
GeneralRe: Argument 1: cannot convert from 'object' to 'string' Pin
OriginalGriff31-Oct-19 2:20
mveOriginalGriff31-Oct-19 2:20 
AnswerRe: Argument 1: cannot convert from 'object' to 'string' Pin
Richard MacCutchan31-Oct-19 1:37
mveRichard MacCutchan31-Oct-19 1:37 
GeneralRe: Argument 1: cannot convert from 'object' to 'string' Pin
User 1460643731-Oct-19 1:57
User 1460643731-Oct-19 1:57 
GeneralRe: Argument 1: cannot convert from 'object' to 'string' Pin
Dave Kreskowiak31-Oct-19 2:16
mveDave Kreskowiak31-Oct-19 2:16 
GeneralRe: Argument 1: cannot convert from 'object' to 'string' Pin
Richard Deeming31-Oct-19 2:45
mveRichard Deeming31-Oct-19 2:45 
QuestionCreate New Label when click button in window form, move it when click and move mouse, and save it again when close file exe Pin
Member 1045263729-Oct-19 21:10
Member 1045263729-Oct-19 21:10 
AnswerRe: Create New Label when click button in window form, move it when click and move mouse, and save it again when close file exe Pin
OriginalGriff29-Oct-19 21:44
mveOriginalGriff29-Oct-19 21:44 
GeneralRe: Create New Label when click button in window form, move it when click and move mouse, and save it again when close file exe Pin
Member 1045263729-Oct-19 23:07
Member 1045263729-Oct-19 23:07 
GeneralRe: Create New Label when click button in window form, move it when click and move mouse, and save it again when close file exe Pin
OriginalGriff29-Oct-19 23:22
mveOriginalGriff29-Oct-19 23:22 
QuestionHow to solve complex captcha in C# Pin
rflprado29-Oct-19 5:53
rflprado29-Oct-19 5:53 
AnswerRe: How to solve complex captcha in C# Pin
OriginalGriff29-Oct-19 5:55
mveOriginalGriff29-Oct-19 5:55 
AnswerRe: How to solve complex captcha in C# Pin
OriginalGriff29-Oct-19 5:56
mveOriginalGriff29-Oct-19 5:56 
Questionc sharp Pin
Member 1115563928-Oct-19 9:41
Member 1115563928-Oct-19 9:41 

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.