Click here to Skip to main content
15,889,281 members
Home / Discussions / C#
   

C#

 
GeneralRe: Modify Top most Pin
Abhinav S2-Jul-12 16:15
Abhinav S2-Jul-12 16:15 
GeneralColor Detection Using Emgu HSV Pin
caoc72-Jul-12 7:12
caoc72-Jul-12 7:12 
AnswerRe: Color Detection Using Emgu Pin
Dave Kreskowiak2-Jul-12 9:01
mveDave Kreskowiak2-Jul-12 9:01 
QuestionDatabinding a DataGridView not immediately available Pin
Dewald2-Jul-12 4:11
Dewald2-Jul-12 4:11 
AnswerRe: Databinding a DataGridView not immediately available Pin
Jasmine25012-Jul-12 5:46
Jasmine25012-Jul-12 5:46 
GeneralRe: Databinding a DataGridView not immediately available Pin
Dewald2-Jul-12 6:30
Dewald2-Jul-12 6:30 
QuestionHow to add annotation to the pdf file viewed by axAcroPdf component Pin
candogu2-Jul-12 3:54
candogu2-Jul-12 3:54 
QuestionHaving trouble connecting with my datasource Pin
deadEddie1-Jul-12 18:38
deadEddie1-Jul-12 18:38 
Hey there, I'm sure there is some simple newbie problem with my code, but I have not been able to figure it out and was hoping another set of eyes would help.

I'm working on a financial accounting tool that so far has two tables, a Users table and an AccountsTransactions table, The below method is from my DatabaseCommunicator class. It builds fine but crashes with a message that the "Balance" column is not in the AccountsTransactions Table. Since I know that the column is in fact in the table, the only thing I can think of as being the problem is that I'm not actually connecting to the datasource and filling the dataset. Can anyone see where I'm going wrong?

Thanks in advance. Confused | :confused:

public string[] CreateNewTransaction(int UserID) // note the use of string[] as the method return type
        {
            // create an array to hold method results
            string[] returnArray = new string[2];

            string selectSql = "SELECT Count(*) FROM AccountTransactions WHERE UserID = @UserID";

            // new SqlConnection
            connect = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename='C:\\Users\\Ed\\Documents\\Visual Studio 2010\\Projects\\School Projects\\Accounts\\Accounts\\Accounts.mdf';Integrated Security=True;User Instance=True");

            // initialize SqlDataAdapter
            dataAdapter = new SqlDataAdapter();

            SqlCommand cmd = new SqlCommand(selectSql, connect);

            dataAdapter.SelectCommand = cmd;

            // parameters for cmd
            cmd.Parameters.AddWithValue("@UserID", UserID);

            // create a new DataSet
            dataSet = new DataSet();
                        
            dataAdapter.Fill(dataSet, "AccountTransactions");

            // create variable equal to the count of rows in the database and set the DataRow to that row number
            int lastRow = dataSet.Tables["AccountTransactions"].Rows.Count-1;
            DataRow dRow = dataSet.Tables["AccountTransactions"].Rows[lastRow];
                        
            returnArray[0] = Convert.ToString(dataSet.Tables["AccountTransactions"].Rows[lastRow]["Balance"]);
            returnArray[1] = Convert.ToString(dataSet.Tables["AccountTransactions"].Rows[lastRow]["TransactionNo"]);

            connect.Dispose();

            return returnArray;
        }

GeneralRe: Having trouble connecting with my datasource Pin
Hum Dum1-Jul-12 19:51
Hum Dum1-Jul-12 19:51 
GeneralRe: Having trouble connecting with my datasource Pin
deadEddie2-Jul-12 5:15
deadEddie2-Jul-12 5:15 
AnswerRe: Having trouble connecting with my datasource Pin
AnnieCalvert1-Jul-12 22:40
AnnieCalvert1-Jul-12 22:40 
GeneralRe: Having trouble connecting with my datasource Pin
deadEddie2-Jul-12 17:59
deadEddie2-Jul-12 17:59 
QuestionTcpClient with Proxy Pin
Falchon1-Jul-12 13:37
Falchon1-Jul-12 13:37 
AnswerRe: TcpClient with Proxy Pin
Luc Pattyn1-Jul-12 14:35
sitebuilderLuc Pattyn1-Jul-12 14:35 
GeneralRe: TcpClient with Proxy Pin
Falchon1-Jul-12 14:53
Falchon1-Jul-12 14:53 
QuestionOdd RuntimeBinderException Pin
LastAndFirst1-Jul-12 0:27
LastAndFirst1-Jul-12 0:27 
AnswerRe: Odd RuntimeBinderException Pin
DaveyM692-Jul-12 1:53
professionalDaveyM692-Jul-12 1:53 
Questioncheck is file created? Pin
Jassim Rahma30-Jun-12 20:24
Jassim Rahma30-Jun-12 20:24 
AnswerRe: check is file created? Pin
Pete O'Hanlon30-Jun-12 20:53
mvePete O'Hanlon30-Jun-12 20:53 
GeneralRe: check is file created? Pin
Abhinav S30-Jun-12 21:08
Abhinav S30-Jun-12 21:08 
GeneralRe: check is file created? Pin
Pete O'Hanlon30-Jun-12 21:16
mvePete O'Hanlon30-Jun-12 21:16 
GeneralRe: check is file created? Pin
Abhinav S1-Jul-12 3:49
Abhinav S1-Jul-12 3:49 
AnswerRe: check is file created? Pin
Luc Pattyn30-Jun-12 22:14
sitebuilderLuc Pattyn30-Jun-12 22:14 
AnswerRe: check is file created? Pin
Dave Kreskowiak1-Jul-12 3:58
mveDave Kreskowiak1-Jul-12 3:58 
QuestionHow to find the number of folders and files in particular folder Pin
jeetveer30-Jun-12 9:40
jeetveer30-Jun-12 9:40 

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.