Click here to Skip to main content
15,887,294 members
Home / Discussions / C#
   

C#

 
GeneralRe: Automatic Font serialization Pin
baranils13-Mar-09 8:34
baranils13-Mar-09 8:34 
GeneralRe: Automatic Font serialization Pin
led mike13-Mar-09 9:10
led mike13-Mar-09 9:10 
GeneralRe: Automatic Font serialization Pin
baranils13-Mar-09 11:13
baranils13-Mar-09 11:13 
GeneralRe: Automatic Font serialization Pin
led mike13-Mar-09 12:00
led mike13-Mar-09 12:00 
GeneralRe: Automatic Font serialization Pin
baranils13-Mar-09 14:13
baranils13-Mar-09 14:13 
QuestionSending Ctrl+letter to application using PostMesssage or SendMessage Pin
Fredrik Hagg13-Mar-09 5:10
Fredrik Hagg13-Mar-09 5:10 
GeneralRe: Sending Ctrl+letter to application using PostMesssage or SendMessage Pin
Luc Pattyn13-Mar-09 6:26
sitebuilderLuc Pattyn13-Mar-09 6:26 
QuestionAdvice about Open Database Connection Pin
soulidentities13-Mar-09 4:46
soulidentities13-Mar-09 4:46 
Hi ppl
Im again
In a data Entry software Most frequently usage is database Connection.
I have to insert data many tables in different forms. So I have to create diff connection for different table insert or update.
Like i have 3 forms. In 3 forms, I have to insert in 3 different table in a same database. So when I insert form1 in table1 then I have to create connection and close connection.
Again for form2 i have to do same jobs.

is there anyway to create one connection for all forms usage and close after manipulating, like "Visual Basic" ,module.
Or
any efficient way to do it?
or
Any Advice pls

Feel free to advice me

A lil detail of my problem:
i have to write all full conn every time.....
disgusting isnt it...like
//connection string
string connString = @"
server = HOME;
integrated security = true;
database = Monitoring
";
//query
string sql = string.Format(@"
SELECT Ins_ID, Ins_Nm
FROM Institution_Profile
WHERE Up_ID =
(SELECT Upazila_ID FROM Upazila
WHERE Upzila_NmB = '{0}')
", cmbUpazila.Text);

//create Connection
SqlConnection conn = new SqlConnection(connString);
try
{
//open Connection
conn.Open();
//create dataAdapter
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
//create dataSet
DataSet ds = new DataSet();
//fill dataset
da.Fill(ds, "Institution_Profile");
// get data table
DataTable dt = ds.Tables["Institution_Profile"];

foreach (DataRow row in dt.Rows)
{
cmbSchoolName.Items.Add(row["Ins_ID"].ToString() + " " + row["Ins_Nm"].ToString());
}
}
catch (Exception ex)
{
MessageBox.Show("Error:" + ex);
}
finally
{
conn.Close();
}

and again write the same code for another table insert or update...

------------
can i write once and use again n again
???

thanks
AnswerRe: Advice about Open Database Connection Pin
Nagy Vilmos13-Mar-09 4:59
professionalNagy Vilmos13-Mar-09 4:59 
GeneralRe: Advice about Open Database Connection Pin
soulidentities13-Mar-09 5:06
soulidentities13-Mar-09 5:06 
QuestionRe: Advice about Open Database Connection Pin
Nagy Vilmos13-Mar-09 5:12
professionalNagy Vilmos13-Mar-09 5:12 
AnswerRe: Advice about Open Database Connection Pin
soulidentities13-Mar-09 5:17
soulidentities13-Mar-09 5:17 
GeneralRe: Advice about Open Database Connection Pin
Dave Kreskowiak13-Mar-09 5:31
mveDave Kreskowiak13-Mar-09 5:31 
GeneralRe: Advice about Open Database Connection Pin
Nagy Vilmos13-Mar-09 10:30
professionalNagy Vilmos13-Mar-09 10:30 
GeneralRe: Advice about Open Database Connection Pin
Dave Kreskowiak13-Mar-09 12:23
mveDave Kreskowiak13-Mar-09 12:23 
AnswerRe: Advice about Open Database Connection Pin
Luc Pattyn13-Mar-09 6:28
sitebuilderLuc Pattyn13-Mar-09 6:28 
QuestionRead lines on exel file Pin
abbd13-Mar-09 4:05
abbd13-Mar-09 4:05 
AnswerRe: Read lines on exel file Pin
Eddy Vluggen13-Mar-09 4:19
professionalEddy Vluggen13-Mar-09 4:19 
QuestionException de HRESULT : 0x800401A8 Pin
abbd13-Mar-09 4:50
abbd13-Mar-09 4:50 
AnswerRe: Exception de HRESULT : 0x800401A8 Pin
Eddy Vluggen13-Mar-09 5:03
professionalEddy Vluggen13-Mar-09 5:03 
GeneralRe: Exception de HRESULT : 0x800401A8 Pin
abbd13-Mar-09 5:07
abbd13-Mar-09 5:07 
GeneralRe: Exception de HRESULT : 0x800401A8 Pin
Eddy Vluggen13-Mar-09 5:28
professionalEddy Vluggen13-Mar-09 5:28 
QuestionRe: Exception de HRESULT : 0x800401A8 Pin
abbd13-Mar-09 5:57
abbd13-Mar-09 5:57 
AnswerRe: Exception de HRESULT : 0x800401A8 Pin
Luc Pattyn13-Mar-09 6:30
sitebuilderLuc Pattyn13-Mar-09 6:30 
QuestionRe: Exception de HRESULT : 0x800401A8 Pin
abbd13-Mar-09 6:54
abbd13-Mar-09 6:54 

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.