|
|
I have a simple web page that is able to access several servers, I just set up the conection string based on a radio button list as in the following example:
Select Case RadioButtonList1.SelectedItem.Value<br />
Case "GlobaldbIBE"<br />
sqlConnString = "Data Source = 222.8.249.18; Integrated Security = False; User ID = sa; Password = ; database = GlobaldbIBE"<br />
Case "oht_dbIBE"<br />
sqlConnString = "Data Source = 222.8.249.18; Integrated Security = False; User ID = sa; Password = ; database = OHT_dbIBE"<br />
Case "KESM"<br />
sqlConnString = "Data Source = 221.14.69.102; Integrated Security = False; User ID = pad; Password = pad; database = dbIBE; Connect Timeout = 60"<br />
Case "Tianjin"<br />
sqlConnString = "Data Source = 10.192.144.21; Integrated Security = False; User ID = sa; Password = ; database = dbIBE; Connect Timeout = 60"<br />
Case "TTM"<br />
sqlConnString = "Data Source = 10.239.212.112; Integrated Security = False; User ID = sa; Password = ; database = dbIBE; Connect Timeout = 60"<br />
As far as I can tell all the servers are configured the same. I can go the the control panel on my computer and add an ODBC connection to any of the servers (using the same connection info), no problem. I can open the enterprise manager and connect to any of the servers, no problem. When I try co connect through the web application one of them fails "access denied or server does not exist"
What would be different about the way I can access the server but my web application can not? Does the web application run in a different context? why woudl that only impact one server?
The only thing I am scratching at now would be that with Enterprise manager I do get a message "code pages do not match" not sure if that is realted or not....
Any help appreciated...
|
|
|
|
|
Have you tried ping the ip address from the web server. Perhaps your web server can not reach one of the sql servers.
Ben
|
|
|
|
|
Yes I can ping it from the web server and from my development station. I can also map a drive, access it through Enterprise manager and a standard ODBC connection..
Mike
|
|
|
|
|
Have you double checked the username and pasword. Perhaps it would be helpful to have the actual error message.
Ben
|
|
|
|
|
Yes, I have double checked the user name and password, I even changed it to use the "sa" account with no password as in my example.
I just tried to run it to verify the error text exactly and it ran just fine... what the hey? I did not change anything... hrmph....
thanks for you help....
|
|
|
|
|
No-e,
I sure hope the connection strings you posted didnt contain the REAL IP address of the servers since you also have shown the username/password values. Second, this wont fix your problem but I would put those connection strings in the web.config then have a function to extract the correct connection string based on the value selected in the radio button group.
" In the next millennium there are two kinds of business, those on the Internet and those out of business"
Bill Gates
"Be nice to nerds. Chances are you'll end up working for one."
Bill Gates
"Let's face it, the average computer user has the brain of a Spider Monkey."
Bill Gates
|
|
|
|
|
Thanks, trust me the names were changed to protect the innocent. I am reasonably new to this, can you provide a very brief primer on how to use the web.config file? (or point me to a resource that explains it?) I did not realize this was an option....
|
|
|
|
|
No-e,
In your web.config add a connectionStrings section right below the <configuration> and <appsettings>:
<connectionStrings>
<clear/>
<add name="ADConn" providername="System.Data.SqlClient" connectionstring="Data Source=YourDataSource;Integrated Security=true; Persist Security Info=True;User ID=YourUserID;User Instance=true"/>
</connectionStrings>
Then create a function to extract the connection string you want like so
Public Shared Function GetConnectionString(ByVal strConnection As String) As String
Dim strReturn As New String("")
If Not String.IsNullOrEmpty(strConnection) Then
strReturn = _
ConfigurationManager.ConnectionStrings(strConnection).ConnectionString
Else
strReturn = _
ConfigurationManager.ConnectionStrings("YourDefaultConnection").ConnectionString
End If
Return strReturn
End Function
" In the next millennium there are two kinds of business, those on the Internet and those out of business"
Bill Gates
"Be nice to nerds. Chances are you'll end up working for one."
Bill Gates
"Let's face it, the average computer user has the brain of a Spider Monkey."
Bill Gates
|
|
|
|
|
Hi,
Check this out.
In web.config file
add key="conn"
value="Server=<servername>;Integrated Security=no;User ID=<user>;PWD=<pwd>;database=<dbname>" />
code-behind file
string ConnectionString =System.Configuration.ConfigurationSettings.AppSettings["conn"];
-- modified at 8:32 Thursday 26th April, 2007
Regards,
Manowj
|
|
|
|
|
Hi Guys,
How can I get the record count of SqlDataReader? Or do you have any other idea?
Below is my asp.net code
Thanks in advance
Dim strConnString As String = ConfigurationManager.ConnectionStrings("MyConnectiStringHere").ConnectionString
Dim sqlConnection1 As New Data.SqlClient.SqlConnection(strConnString)
Dim cmd As New Data.SqlClient.SqlCommand
Dim reader As Data.SqlClient.SqlDataReader
Dim ds As Data.DataSet
cmd.CommandText = "Select * From tblCategories"
cmd.CommandType = Data.CommandType.Text
cmd.Connection = sqlConnection1
sqlConnection1.Open()
reader = cmd.ExecuteReader()
If reader.RecordsAffected > 0 Then
MsgBox("have records")
End If
reader.Close()
sqlConnection1.Close()
hifiger2004
|
|
|
|
|
With a datareader, you don't know how many records you've got until you reach the end. To get the count, you would have to increment a variable. The alternative is to read the data into a DataTable/DataSet and get the information from the Rows.Count.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
If you only want to know the number of records, count them in the SQL query:
"select count(*) from tblCategories"
That way you will only get the information you want from the database, instead of all the data in the entire table.
---
single minded; short sighted; long gone;
|
|
|
|
|
This is a slightly dangerous technique because the select of the records could actually return a different number of records because of CRUD operations.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
What do you mean?
---
single minded; short sighted; long gone;
|
|
|
|
|
If you do a select count on a busy database, by the time you do your actual select of the records the criteria may return different results because of inserts, updates or deletes. I've seen too many systems make this assumption, which works fine when there are only one or two users, but when it ramps up to 1000 users then things get a little bit screwy.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
But that is a whole different can of worms....
Brad
Australian
- Me on "Public interest"
If you actually read this let me know.
|
|
|
|
|
Pete O`Hanlon wrote: If you do a select count on a busy database, by the time you do your actual select of the records the criteria may return different results because of inserts, updates or deletes.
Yes, of course, but it makes no difference if you select all records and count them, or if you count the records. The result is equally outdated when you get it.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi Guys,
I think it's the same thing when using the "select count" or rows.count. And I am sure if there are a lot of users out there accessing and doing transactions at the same time, then for sure not all of them will do the same function "delete". I hope not
Anyway, either I will be using a Select count or rows.count, both will work for me.
Right now, I am using the code below:
if ds.Tables.Item(0).Rows.Count > 0 then
do process....
end if
Thank you Guys.
hifiger2004
|
|
|
|
|
Hi All,
How to Find the Flash version in client's PC? We are developing Flash chat application, in that we have to check Whether the User having Flash when they access our chat application,
So plz help me how to find the version.
Thanks in Advance
|
|
|
|
|
Hi i did this check using Javascript find below the script
<SCRIPT LANGUAGE="Javascript">
<!--
var flashinstalled = 0;
var flashversion = 0;
MSDetect = "false";
if (navigator.plugins && navigator.plugins.length)
{
x = navigator.plugins["Shockwave Flash"];
if (x)
{
flashinstalled = 2;
if (x.description)
{
y = x.description;
flashversion = y.charAt(y.indexOf('.')-1);
}
}
else
flashinstalled = 1;
if (navigator.plugins["Shockwave Flash 2.0"])
{
flashinstalled = 2;
flashversion = 2;
}
}
else if (navigator.mimeTypes && navigator.mimeTypes.length)
{
x = navigator.mimeTypes['application/x-shockwave-flash'];
if (x && x.enabledPlugin)
flashinstalled = 2;
else
flashinstalled = 1;
}
else
MSDetect = "true";
</SCRIPT>
-- modified at 8:33 Monday 30th April, 2007
WaelA
Software Engineer
WaelA@hotmail.com
|
|
|
|
|
Hey mate, that is a nice piece of script there, could I recommend that you place it in PRE tags so that it is easier to read (especially with so many nested statements).
Brad
Australian
- peterchen on "Who has the worst keyboard"
Keyboard? Ha! I throw magnets over the RAM chips!
|
|
|
|
|
Be My Guest Done
WaelA
Software Engineer
WaelA@hotmail.com
|
|
|
|
|
I need a a piece of javascript that causes firefox to redirect to another location on-load, this is part of a javascript compatibility check.
Window.Location does not work as it is IE Specific
Le Roux Viljoen
Web Developer
PCW New Media
South African Branch
www.pcwnewmedia.com
|
|
|
|
|
Chona1171 wrote: Window.Location does not work as it is IE Specific
No, it isn't
Brad
Australian
- unknown PHP Developer on "Job Prospect"
Requirement: * Experience working with XML, XSL, XPath
Comment: and other things starting with X.
|
|
|
|