• (3 Pages)
  • +
  • 1
  • 2
  • 3

SQL Basics in C#

#16 brandon277  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 30-April 09

Posted 30 April 2009 - 01:35 AM

string strReturn = new string("");


Guys ... I dunno what I'm doing wrong, but I'm getting an error on this:
"The best overloaded method match for 'string.String(char[])' has some invalid arguments" ...
Not quite sure what's up, as I'm just starting to learn C# ... :blush:
Was This Post Helpful? 0
  • +
  • -

#17 papuccino1  Icon User is offline

  • His name was Robert Paulson.
  • member icon

Reputation: 62
  • View blog
  • Posts: 1,121
  • Joined: 02-March 08

Posted 29 May 2009 - 07:00 PM

I'm having this problem as well, but I think the line should read:

string strReturn = "";

At least I think it should be that way.
Was This Post Helpful? 0
  • +
  • -

#18 Pretty_White_Vampire  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 31-May 09

Posted 31 May 2009 - 09:05 PM

Good Day. I'm using the following codes to connect my project to SQL database.
What's the difference between the codes you were using because I'm having problems with remote connections.

using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace MySystem
{
	static class Program
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		public static string connection = "Server=Computer_Name\\SQLEXPRESS; Database= MySystemDatabase; integrated security=true";
		[STAThread]
		static void Main()
		{
			Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);
			Application.Run(new Form1());
		}
	}
}



using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Text; 
using System.Windows.Forms; 
using System.Data.SqlClient;



  SqlConnection connect = new SqlConnection(Program.connection);

This post has been edited by Pretty_White_Vampire: 31 May 2009 - 09:07 PM

Was This Post Helpful? 0
  • +
  • -

#19 MarmiteX1  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 159
  • Joined: 17-October 09

Posted 18 January 2010 - 09:42 AM

Hi,

Sorry to bother, but I was wondering if you could assist me please with this database issue i am having?

I would like to the values from the textboxes and update the values of a particular row that I have selected and save the permanantly but tat he moment it doesnt save it permanantly.

I have attempted to solve this but i am still having problems.

Here is the link for further details:

http://www.dreaminco...h...=150287&hl=

I would appreciate if you could look into this please?

Thanks
Was This Post Helpful? 0
  • +
  • -

#20 Guest_Zubeyr*


Reputation:

Posted 26 March 2010 - 05:24 PM

Hello I want to learn how can I save my new data base table in some new type and how can I use this table in Visual C#
Was This Post Helpful? 0

#21 royjm248  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 51
  • Joined: 18-January 08

Posted 06 April 2010 - 05:24 PM

Hi, the tutorial looked great, but all i get is "Error 1 The type or namespace name 'BindingSource' could not be found (are you missing a using directive or an assembly reference?)"
Was This Post Helpful? 0
  • +
  • -

#22 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1633
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Posted 06 April 2010 - 05:34 PM

BindingSource is a member of the System.Windows.Forms Namespace
Was This Post Helpful? 0
  • +
  • -

#23 Guest_lobna*


Reputation:

Posted 12 May 2010 - 04:24 PM

i can put data in data table
but is it possible to take data from data table and put it in data base "MS Access" ?
Thanks in advance
Was This Post Helpful? 0

#24 chris71  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-October 10

Posted 17 November 2010 - 05:08 AM

what is the difference between VB^ and C Sharp? :smile2:
Was This Post Helpful? 0
  • +
  • -

#25 milad.cia  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 04-December 10

Posted 10 December 2010 - 06:01 AM

Quote

what is the difference between VB^ and C Sharp?

i think C# is more powerful.

i worked with VB and C# both
and i like C#. its easy and power full.

This post has been edited by milad.cia: 10 December 2010 - 06:03 AM

Was This Post Helpful? 0
  • +
  • -

#26 gacanepa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 03-June 11

Posted 03 June 2011 - 07:11 AM

Hi guys, this may be an old thread but just came in handy for me, and I decided to join this forum because this tutorial and all the others are fantastic. Just a quick note: I was getting an error "ConfigurationManager does not exist in the current context" so this is what I found out: To use ConfigurationManager, It's not only necessary to use the namespace System.Configuration. You have also to add the reference to the assembly System.Configuration.dll , by right-click-ing on the References tab, choose add reference and then find System.Configuration.
Source: http://www.codeguru....p/t-409163.html
Was This Post Helpful? 0
  • +
  • -

#27 gacanepa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 03-June 11

Posted 03 June 2011 - 08:21 AM

Quote

There's a problem in the "Try" "Catch" area, it gives an error "not all code paths return a value" From what I researched and found is that it is because, "nothing is returned if the try block throws an exception and it is caught by the catch block"

Has this issue been resolved?
Was This Post Helpful? 0
  • +
  • -

#28 pietomb00  Icon User is offline

  • D.I.C Head

Reputation: 12
  • View blog
  • Posts: 68
  • Joined: 28-June 11

Posted 08 August 2011 - 07:31 AM

I have a few errors when compiling that I'm just clueless about.

case ConnectionState.Open: //the connection is open
                    //close then re-open
                    oCn.Close();
                    oCn.Open();
                    break;
                case ConnectionState.Closed: //connection is open
                    //open the connection



The name "connectionState" does not exist in the current context.

and

  oBindingSource.DataSource = dtGet;



doesn't contain a definition for datasource, or extension method, (missing a using directive or an assembly reference?)

Thanks.
Was This Post Helpful? 0
  • +
  • -

#29 Darkmatter5  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 28-January 10

Posted 07 August 2012 - 08:13 AM

I'm getting an error in the GetBindingsource function.

It gets to the try/catch at da.Get(dtGet);

The error says, "Error in GetBindingSource" "Fill: SelectCommand.Connection property has not been initialized."

Here's my GetBindingSource code.

public static BindingSource GetBindingSource(SqlCommand cmdSql)
{
  BindingSource oBindingSource = new BindingSource();
  SqlDataAdapter daGet = new SqlDataAdapter(cmdSql);
  DataTable dtGet = new DataTable();
  cmdSql.CommandTimeout = 240;
  dtGet.Locale = System.Globalization.CultureInfo.InvariantCulture;
  try
  {
    daGet.Fill(dtGet);
  }
  catch (Exception ex)
  {
    MessageBox.Show(ex.Message, "Error in GetBindingSource");
    return null;
  }
  oBindingSource.DataSource = dtGet;
  return oBindingSource;
}



Any ideas?
Was This Post Helpful? 0
  • +
  • -

#30 probuddha  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 15-January 13

Posted 15 January 2013 - 06:55 AM

How to connect to an SQL-Server:
http://www.programme...-to-sql-server/
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3