Click here to Skip to main content
15,881,793 members
Home / Discussions / C#
   

C#

 
QuestionSQL Server 2008 in C# Console Appications Pin
bigjoe11a30-May-09 4:09
bigjoe11a30-May-09 4:09 
AnswerRe: SQL Server 2008 in C# Console Appications Pin
Mbah Dhaim30-May-09 5:17
Mbah Dhaim30-May-09 5:17 
GeneralRe: SQL Server 2008 in C# Console Appications Pin
bigjoe11a30-May-09 5:35
bigjoe11a30-May-09 5:35 
AnswerRe: SQL Server 2008 in C# Console Appications Pin
Henry Minute30-May-09 7:48
Henry Minute30-May-09 7:48 
GeneralRe: SQL Server 2008 in C# Console Appications Pin
bigjoe11a30-May-09 8:17
bigjoe11a30-May-09 8:17 
GeneralRe: SQL Server 2008 in C# Console Appications Pin
bigjoe11a30-May-09 8:33
bigjoe11a30-May-09 8:33 
GeneralRe: SQL Server 2008 in C# Console Appications Pin
Henry Minute30-May-09 8:59
Henry Minute30-May-09 8:59 
GeneralRe: SQL Server 2008 in C# Console Appications Pin
bigjoe11a30-May-09 9:08
bigjoe11a30-May-09 9:08 
well I'm getting some errors on some of the lines. So I can't compile yet.
I do know that some of of it is missing. My code is below

string UserConnection = Properties.Settings.Default.UsersConnectionString;
SqlConnection MyConnection = new SqlConnection(UserConnection);

String MyString = @"INSERT INTO UserData (Name, telnetaddr) VALUES('" + addr.name.ToString().TRIM() + "', '" + addr.telnetaddr.ToString().Trim() + "')";

SqlCommand command = new SqlCommand(MyString, MyConnection);
//command.Parameters.Add("@ID", SqlDbType.Int);
//command.Parameters["@ID"].Value = ID;
command.Parameters.Add("@Name", SqlDbType.Text);
command.Parameters["@Name"].Value = addr.name;
command.Parameters.Add("@telnetaddr", SqlDbType.Text);
command.Parameters["@telnetaddr"].Value = addr.telnetaddr;

// Use AddWithValue to assign Demographics.
// SQL Server will implicitly convert strings into XML.
command.Parameters.AddWithValue(commandText, );

try
{
MyConnection.Open();
Int32 rowsAffected = command.ExecuteNonQuery();
Console.WriteLine("RowsAffected: {0}", rowsAffected);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}

Error 1 Argument missing C:\Users\Joe\Documents\Visual Studio 2008\Projects\MyDoor\Program.cs 245 66 MyDoor

Error 2 'string' does not contain a definition for 'TRIM' and no extension method 'TRIM' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) C:\Users\Joe\Documents\Visual Studio 2008\Projects\MyDoor\Program.cs 233 114 MyDoor

Error 3 The name 'commandText' does not exist in the current context C:\Users\Joe\Documents\Visual Studio 2008\Projects\MyDoor\Program.cs 245 53 MyDoor

What I should have ask if some one could type out the full code So I know I get every thing right.
GeneralRe: SQL Server 2008 in C# Console Appications Pin
Henry Minute30-May-09 9:14
Henry Minute30-May-09 9:14 
GeneralRe: SQL Server 2008 in C# Console Appications Pin
Henry Minute30-May-09 9:22
Henry Minute30-May-09 9:22 
GeneralRe: SQL Server 2008 in C# Console Appications Pin
bigjoe11a30-May-09 9:59
bigjoe11a30-May-09 9:59 
GeneralRe: SQL Server 2008 in C# Console Appications Pin
Henry Minute30-May-09 10:43
Henry Minute30-May-09 10:43 
GeneralRe: SQL Server 2008 in C# Console Appications Pin
bigjoe11a30-May-09 11:31
bigjoe11a30-May-09 11:31 
GeneralRe: SQL Server 2008 in C# Console Appications Pin
Henry Minute30-May-09 11:52
Henry Minute30-May-09 11:52 
GeneralRe: SQL Server 2008 in C# Console Appications Pin
bigjoe11a30-May-09 12:03
bigjoe11a30-May-09 12:03 
QuestionUpdating changings back to DB from DataGridView Pin
WinSolution30-May-09 3:11
WinSolution30-May-09 3:11 
AnswerRe: Updating changings back to DB from DataGridView Pin
Henry Minute30-May-09 4:12
Henry Minute30-May-09 4:12 
AnswerRe: Updating changings back to DB from DataGridView Pin
I Believe In GOD30-May-09 10:08
I Believe In GOD30-May-09 10:08 
GeneralRe: Updating changings back to DB from DataGridView Pin
Henry Minute30-May-09 10:51
Henry Minute30-May-09 10:51 
GeneralRe: Updating changings back to DB from DataGridView Pin
I Believe In GOD30-May-09 12:38
I Believe In GOD30-May-09 12:38 
GeneralRe: Updating changings back to DB from DataGridView Pin
WinSolution31-May-09 1:31
WinSolution31-May-09 1:31 
GeneralRe: Updating changings back to DB from DataGridView Pin
I Believe In GOD31-May-09 1:49
I Believe In GOD31-May-09 1:49 
QuestionGet the absolute pix of Html Element Using mshtml Pin
Member 437807730-May-09 3:00
Member 437807730-May-09 3:00 
QuestionPlease help Pin
Etienne_12330-May-09 1:57
Etienne_12330-May-09 1:57 
AnswerRe: Please help Pin
Henry Minute30-May-09 4:02
Henry Minute30-May-09 4:02 

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.