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

C#

 
GeneralRe: best way to use c++ code in c# project Pin
Luc Pattyn11-Aug-09 5:05
sitebuilderLuc Pattyn11-Aug-09 5:05 
AnswerRe: best way to use c++ code in c# project Pin
N a v a n e e t h11-Aug-09 4:26
N a v a n e e t h11-Aug-09 4:26 
AnswerRe: best way to use c++ code in c# project Pin
Hristo-Bojilov11-Aug-09 5:52
Hristo-Bojilov11-Aug-09 5:52 
QuestionSourceGrid customise Pin
Parth Gandhi11-Aug-09 3:40
Parth Gandhi11-Aug-09 3:40 
AnswerRe: SourceGrid customise Pin
Henry Minute11-Aug-09 4:52
Henry Minute11-Aug-09 4:52 
GeneralRe: SourceGrid customise Pin
Parth Gandhi18-Aug-09 2:04
Parth Gandhi18-Aug-09 2:04 
GeneralRe: SourceGrid customise Pin
Henry Minute18-Aug-09 2:15
Henry Minute18-Aug-09 2:15 
QuestionUpdate SQL Server 2005 table with DataGrid contents Pin
Wheels01211-Aug-09 3:35
Wheels01211-Aug-09 3:35 
Good morning.

I have populated a DataGridView with a dataset from a query off a table in SQL Server 2005. Now when a user makes changes in the DataGridView and clicks on a 'Save' button, I want the dataset to be updated and the table to reflect the changes. The datagrid is on a form and all the queries are called from the DAL.

My code is as follows:

private void btnQuery_Click_1(object sender, EventArgs e) 
{ 
PwdSecurity p = new PwdSecurity(); 
uipc = this.Parent as UIPCMainForm; 
const string constrallowedBlockTypes = "allowedBlockTypes"; 
DAL d = new DAL(uipc.StrUserName, p.base64Decode(uipc.StrPassword)); 

DataSet ds = new DataSet(); 
ds = d.AllowedTypes(constrallowedBlockTypes); // Returns dataset correctly from method in DAL 

//New code 
BindingSource bs = new BindingSource(); 
bs.DataSource = ds; 
bs.DataMember = ds.Tables[0].TableName; 
dgv.DataSource = bs; 

// End new code 
} 

DAL: 

myConnection = 
new SqlConnection("server=PTLLBNB0DD1\\SQLSERVER2005;database=IPControl;Trusted_Connection=yes"); 

public DataSet AllowedTypes(string Type) 
{ 
string SQL = String.Empty; 
ds = new DataSet(); 
try 
{ 
SqlCmd = new SqlCommand("spGET_ALLOWED_TYPE", myConnection); 
SqlCmd.CommandType = CommandType.StoredProcedure; 
SqlCmd.Parameters.Add("@Type", SqlDbType.VarChar, 50); 
SqlCmd.Parameters["@Type"].Value = constrallowedDeviceTypes; 

if (myConnection != null) { myConnection.Close(); } 

myConnection.Open(); 
SqlAdapt = new SqlDataAdapter(SqlCmd); 
SqlAdapt.Fill(ds); 
} 
catch (Exception e) 
{ 
MessageBox.Show("DAL Layer / AllowedTypes method error. \n\r \n\r" + 
e.Message.ToString() + " \n\r \n\r" + SQL); 
} 
finally 
{ 
if (con != null) { con.Close(); } 
if (aCommand != null) { aCommand.Dispose(); } 
if (adapter != null) { adapter.Dispose(); } 
} 

return ds; 
} 

If I had access to the SqlAdapt, I could probably use SqlAdapt.Update(ds), but i don't currently.

Any suggestions?

WHEELS
QuestionI want to load a button in the title bar Pin
flydk11-Aug-09 3:28
flydk11-Aug-09 3:28 
AnswerRe: I want to load a button in the title bar Pin
Saksida Bojan11-Aug-09 4:23
Saksida Bojan11-Aug-09 4:23 
GeneralRe: I want to load a button in the title bar Pin
flydk11-Aug-09 14:41
flydk11-Aug-09 14:41 
GeneralRe: I want to load a button in the title bar Pin
Saksida Bojan12-Aug-09 8:19
Saksida Bojan12-Aug-09 8:19 
GeneralRe: I want to load a button in the title bar Pin
flydk12-Aug-09 19:09
flydk12-Aug-09 19:09 
QuestionReplace(@"\\", @"\") not working Pin
dptalt11-Aug-09 3:22
dptalt11-Aug-09 3:22 
AnswerRe: Replace(@"\\", @"\") not working Pin
Andrew Rissing11-Aug-09 3:58
Andrew Rissing11-Aug-09 3:58 
GeneralRe: Replace(@"\\", @"\") not working Pin
dptalt11-Aug-09 4:04
dptalt11-Aug-09 4:04 
Questionhow to get data from the tags of a TIFF image Pin
gilvani11-Aug-09 3:05
gilvani11-Aug-09 3:05 
AnswerRe: how to get data from the tags of a TIFF image Pin
Luc Pattyn11-Aug-09 3:21
sitebuilderLuc Pattyn11-Aug-09 3:21 
QuestionHow to apply RowFilter for a String Date Pin
Sreedhar Kadiyala11-Aug-09 3:02
Sreedhar Kadiyala11-Aug-09 3:02 
AnswerRe: How to apply RowFilter for a String Date Pin
dptalt11-Aug-09 3:49
dptalt11-Aug-09 3:49 
AnswerRe: How to apply RowFilter for a String Date Pin
Anjups7-Sep-09 20:40
Anjups7-Sep-09 20:40 
QuestionDateTime.TryParseExact() problem? Pin
Henk Meijerink11-Aug-09 2:46
Henk Meijerink11-Aug-09 2:46 
AnswerRe: DateTime.TryParseExact() problem? Pin
stancrm11-Aug-09 2:57
stancrm11-Aug-09 2:57 
GeneralRe: DateTime.TryParseExact() problem? Pin
Henk Meijerink11-Aug-09 3:45
Henk Meijerink11-Aug-09 3:45 
QuestionUpdated:Filter for DataGridView [modified] Pin
janadhana11-Aug-09 2:14
janadhana11-Aug-09 2:14 

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.