|
I suspect you are creating the SqlConnection somewhere else from where you actually need it. If you can handle not having a SQL Server installed in some places in your code, then the connection object shouldn't be known to those sections of code. What I mean is, only create a SqlConnection directly inside the code that uses it.
|
|
|
|
|
Why you posted seems like the best way to me...
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have a page that on load it connects to an access database to retrieve records. However whenever I post an event (such as inserting information into the database) I get a database unavailable (per my try/catch statement I defined) meaning that the db did not connect. I am using the same connection string to connect to the database. Another note to consider is that locally I was able to do the insert just fine.
Here's the connection string code for the onload:
//create an open string
string conString = @"Provider=Microsoft.JET.OLEDB.4.0;" + @"data source=" + Server.MapPath("/App_Data/td.mdb");
//create an open the connection
OleDbConnection conn = new OleDbConnection(conString);
conn.Open();
sql = "Select * from Guest_Book ORDER BY gb_date DESC";
OleDbCommand command = new OleDbCommand(sql, conn);
OleDbDataReader the_Reader = command.ExecuteReader();
Here's the connection string code for the posted event:
//create an open string
string conString = @"Provider=Microsoft.JET.OLEDB.4.0;" + @"data source=" + Server.MapPath("/App_Data/td.mdb");
//create an open the connection
OleDbConnection conn = new OleDbConnection(conString);
conn.Open();
sql = "Insert Into Guest_Book (gb_name, gb_email, gb_msg, gb_date) VALUES ('" + name + "','" + email + "','" + message + "','" + DateTime.Now.ToShortDateString() + "')";
OleDbCommand command = new OleDbCommand(sql,conn);
command.ExecuteReader();
Is there something that I'm missing. All suggestion welcome. Thank you.
|
|
|
|
|
I think u should try to create DSN for connection.
rahul
|
|
|
|
|
|
Hello ! Someone here, kindly help me.
I have a file Dataset1.xsd that contains 2 table adapters in one-to-many relation (tblOrder and tblOrderDetail)and Relation link of two tables throughout tblOrder.OrderID = tblOrderDetail.OrderID(of course tables contains related data in database)
I know how to use dataset to assign for Datagrid datasource to make hierachical data in grid. I assigned datagrid1.datasource = tblOrderBingdingSource.
When I run this program, then I click an item in parent data, surely child data will appear but tblOrderDetail.OrderID only appears, other columns have null values although I assigned the other columns specified values.
I don't know why so ?
Help me.
Thanks in advance
-- modified at 4:46 Tuesday 27th March, 2007
|
|
|
|
|
I'm trying to learn C# coding and I've gotten to a point where I have a question. More or less.
If you have two methods like below
public static void MethodOne()
{
result a;
}
public static void MethodTwo()
{
result b;
}
Can you use "result a" in methodTwo? I am assuming that "result a" is saved in its variable. If so what is the calling method?
Thanks for any input, its appreciated.
P.S. - Sorry about the other message with the same name. I think that I hit the wrong button.
|
|
|
|
|
JMOdom wrote: Can you use "result a" in methodTwo?
What do you mean by result a ? If it's a variable, no. It needs to be a member.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
OK, exchange "results a" and "results b" for "return a" and "return b".
|
|
|
|
|
If you return it, then you'd need to pass it as a parameter. Otherwise, it's out of scope, unless it's a member.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
To add to what Christian told you, you will have to change the return type from void to whatever a and b are.
Cheers,
Vikram.
The cold will freeze our stares
We won't care...
|
|
|
|
|
Its a matter of scope
If you have the following;
static int resulta = 0;
public static void MethodOne()
{
result a;
}
public static void MethodTwo()
{
result b;
result a; //Is legal
}
then result a can be referenced in MethodTwo
but if you have
public static void MethodOne()
{
int result a;
}
public static void MethodTwo()
{
result b;
result a; //Is not valid because it is not in scope
}
Hope this helps and that I understood you correctly
Mike
Everybody gotta be somebody
|
|
|
|
|
|
You want to try again ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Morning! I am calculating a percentage and the float value is, say 12.34567, I know float has 7 digits precision, is there any easy way to set the precision to 4 or 2 digits after .? So that I have 12.3 or 12.34, Thanks a lot.
|
|
|
|
|
for rendering, you can use string.format("0.###"), with a # for each level of precision. You can't change what a float can store, however.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thank you very much for your quck help, you gave me a thought of doing it in a different way, the actual code is String.format({0:#.##}, float).
|
|
|
|
|
Yes, that also works.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi
i have a code like this:
float f = d / (c * b * a) / 1000000;
string.Format("{0 .00}",f);
txtdansite1.Text = f.ToString();
it still does not work and it has the float`s default precision.
help me please
|
|
|
|
|
Console.WriteLine("{0:N2}",value);
(M.BALA SUBRAMANYAM)
|
|
|
|
|
in win application we don`t use console and this syntax does not help,for example:
textbox1.text=string.format("{0:n2}", variable);
and the textbox1 shows: 0.00
|
|
|
|
|
Or simply use
Math.Round(floatvalue,2);
Sujith
|
|
|
|
|
float f=2.37037E-08
Math.Round(f, 2);
textbox1.Text = f.ToString();
still the same problem and the textbox shows 2.37037E-08
|
|
|
|
|
hi
how to copy folders ??
|
|
|
|
|
I'm not sure if there's a Directory.Copy, I don't think so. I suspect you need to create the folder and copy the files recursively.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|