|
hai
i have a problem in connecting sqlserver
my connection string is
con = New SqlConnection("Network Library =DBMSSOCN; server = 210.211.225.48; database = CarDb; user id = sas; password =poi098;timeout = 60")
but it is giving the following error
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
please help me
Thanks in advance
Vijay Kumar
|
|
|
|
|
Hi,
at first you should check your connection string (the 'network library'-key seems not necessary to me).
Have a look at
http://www.connectionstrings.com/sql-server-2005[^]
to verify.
If this does not work check if the sql server allows remote connection. To do this, connect to the server (RDP) and open the network configuration of the sql server. There you should specify the allowed protocols. Also open the server in the management view and check if the flag is set to allow remote connections.
For more details, have a look here:
http://support.microsoft.com/?scid=kb%3Ben-us%3B914277&x=12&y=4[^]
Regards
Sebastian
|
|
|
|
|
thanks for u r reply
but i m not using SQL server 2005
im using sql server 2000
and how should i configure -- allowed protocols and remote connection
|
|
|
|
|
|
even it not solved the problem
every thing is ok,
remote connection is also allowed
is there any thing else
|
|
|
|
|
Did you tried to use another connection string (without the network library)? Check if you can access the server from your client by using the management application of sql server.
|
|
|
|
|
have you allowed sql server to make remote connection?
Please don't forget to mark 'Good Answer', if you find it really a good one!
Kashif
|
|
|
|
|
hi
thanks for u r reply
i allowed sqlserver to make remote connection
but i have a doubt
my server ip address is changed then
should i do any settings to sqlserver 2000 regarding this
ip address
How the new ip address will be connected to sqlserver 2000
|
|
|
|
|
just check your ports are open which it's accessing remotely
Please don't forget to mark 'Good Answer', if you find it really a good one!
Kashif
|
|
|
|
|
Hello,I have a case scenario and will appreciate if some one help me.
1) I have small Inn which has a series room and people. the owner need people from Korea insert their specific details.
I define the classes as below:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.ComponentModel;
namespace DuryHouse.Repository.BusinessLayer
{
public class Room
{
public int _id = -1;
public int _bed = -1;
public int _floor = -1;
public string _roomName = string.Empty;
public string _type = string.Empty;
[DataObjectFieldAttribute(true, true, false)]
public int Id
{
set { _id = value; }
get { return _id; }
}
public int Bed
{
set { _bed = value;
if (value > 10)
{ throw new ArgumentException(string.Format("Maximum bed is 10!!!")); }
}
get { return _bed; }
}
public int Floor
{
set { _floor = value; }
get { return _floor; }
}
public string RoomName
{
set { _roomName = value; }
get { return _roomName; }
}
public string Type
{
set { _type = value; }
get { return _typeass; }
}
public Room(int id, int bed, int floor, string roomName, string type)
{
this._id = id;
this._bed = bed;
this._floor = floor;
this._roomName = roomName;
this._type = type;
}
}
}
next class is for people
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.ComponentModel;
namespace DuryHouse.Repository.BusinessLayer
{
public class People
{
protected int _id = -1;
protected string _name = string.Empty;
protected string _passportNumber = string.Empty;
protected string _naionality = string.Empty;
[DataObjectFieldAttribute(true, true, false)]
public int Id
{
set { _id = value; }
get { return _id; }
}
public int Name
{
set { _name = value; }
get { return _name; }
}
public int PassportNumber
{
set { _passportNumber = value; }
get { return _passportNumber; }
}
public int Nationality
{
set { _naionality = value; }
get { return _naionality; }
}
public People(int id, string name, string passportNumber, string nationality)
{
this._id = id;
this._name = name;
this._passportNumber = passportNumber;
this._naionality = nationality;
}
public People()
{
}
}
}
then I have another class Korea which inherit from People
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
namespace DuryHouse.Repository.BusinessLayer
{
public class Korea:People
{
public string _city = string.Empty;
public string _state = string.Empty;
public string _street = string.Empty;
public string _phone = string.Empty;
public string _mobile = string.Empty;
public string _email = string.Empty;
public string City
{
set { _city = value; }
get { return _city; }
}
public string State
{
set { _state = value; }
get { return _state; }
}
public string Street
{
set { _street = value; }
get { return _street; }
}
public string Phone
{
set { _phone = value; }
get { return _phone; }
}
public string Mobile
{
set { _mobile = value; }
get { return _mobile; }
}
public string Email
{
set { _email = value; }
get { return _email; }
}
public Korea(int id, string name, string passportNumber, string nationality
, string city, string state, string street, string phone, string mobile, string email) :
base(id, name, passportNumber, nationality)
{
this._city = city;
this._state = state;
this._street = street;
this._phone = phone;
this._mobile = mobile;
this._email = email;
}
}
}
because of I am practicing on inheritance just wondering to know am I in right track? do I get the meaning? by the way if you have any suggestion or idea regarding Inn please let me know.I know I should define another class checkInOut and transaction.
|
|
|
|
|
First, if you post is long- please say so in the Subject line(like mine), people will down vote you otherwise.
You seem to have grasped the basic idea of inheriting. You should also consider defining Interface s for your classes, and work with the interface rather than the concrete type.
Your class names are a little confusing (probably just a langauge or typo thing), but it is important for clarity to get these right. People only defines one person so call the class Person simlarly the class Korea should be Korean or KoreanPerson or similar.
Finally, I've a few sytanx suggestion, see the code below:
public class Person
{
public int Id { get; set; }
public int Name { get; set; }
public People(int id, string name, string passportNumber, string nationality)
{
Id = id;
Name = name;
}
public People()
{
Id = -1
}
}
|
|
|
|
|
thanks for you reply. Could you please explain a little more about this sentence.
You should also consider defining Interfaces for your classes, and work with the interface rather than the concrete type.
why do I have to use interface. please explain a bit more.
thx
|
|
|
|
|
An Interface just defines what Methods / Properties / Events etc must be publicly available, how to achieve it is the responsibility of the class. So the person Interface might look like:
public Interface IPerson
{
int Id { set; get; }
int Name { set; get; }
int PassportNumber { set; get; }
int Nationality { set; get; }
void SomeFictionalMethod();
}
Note that the Interface declares public members, so you don't (in fact can't) state the visibilty. You can Generate a Interface by right-clicking on the class name --> Reafactor --> Extract interface.
You don't have to use an Interface, but it is good practise. I can't think of a meaningful explanation for your example, so here's a simplified one. Let's say you have need to model modes of transport, that all expose two methods Go And Stop . A horse is a mode of transport, but so is a car, the implementation of these would be totally different so a common base class doesn't make sense. The solution that makes the most symantic sense is to create and IModeOfTransport interface and have both the Horse and Car implement it. Now let's suppose your Person object needs a ModeOfTransportProperty you can Declare it:
public class Person : IPerson
{
public IModeOfTransport {get; set;}
}
Now you can pass any object in the inherits from IModeOfTransport , even if they don't have the same base class, this help to decouple the code.
|
|
|
|
|
Dear All,
I have two web pages, say SourceWebPage and TargetWebPage, on the TargetWebpage I have a directive like:
<%@ PreviousPageType VirtualPath = "~/SourceWebPage.aspx" %>
These are the code behand on TargetWebPage Page_Load Event:
if (!Page.IsPostBack)
{
if (Page.PreviousPage != null && Page.PreviousPage.IsCrossPagePostBack)
{
DateTime reportDate = PreviousPage.DTReportDate;
string serialNo = PreviousPage.SerialNo;
}
else
{
LoadReportType();
odsSyncSummaryReport.FilterExpression = GetObjDSFillerExpression();
gvSyncSummaryReport.DataSourceID = "odsSyncSummaryReport";
gvSyncSummaryReport.DataBind();
}
}
else
{
odsSyncSummaryReport.FilterExpression = GetObjDSFillerExpression();
}
there is a link button on SourceWebPage like this: OnClick = "lbSerialNo_Click" PostBackUrl = "~/TargetWebPage.aspx".
Both pages are able to be accessed by click on the menu, when I go to SourceWebPage first and then click the link button, it posts back to the TargetWebPage and everything works fine. But the problem is when i go to the TargetWebPage first, it throws an exception.
I think i know the problem because the PreviousPage property (SourceWebPage) hasn't been loaded yet, therefor there is no way that the TargetWebPage to get the value from SourceWebPage. What i want to know in here is how do I know whether the TargetWebPage is posted from SourceWebPage or it is posted from Menu. This piece of code doesn't help me at all: if (Page.PreviousPage != null && Page.PreviousPage.IsCrossPagePostBack)
I was googling for hours but without any luck, can someone in here shed me a light?
Thanks
|
|
|
|
|
You could check the HTTP_REFERER server variable.
Also, please remember to format any code you post using pre tags
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thanks a lot mate, your post does help me and to help the others further, this is the code (in c#) that does the trick:
if (Request.ServerVariables["HTTP_REFERER"].EndsWith("xxx.aspx"))
|
|
|
|
|
Hi,
I learned that, if I use image height and image width attribute in html than, the page loads faster because the internet explorer wont need to calculate the image dimension. So, in my ASP.NET code behind file, I calculate the image from server and render html code with appropriate height and width attribute for image. Now, I am wondering, if I dont calculate the image height and image width in server and let the browser calculate it on the fly when rendering, will that be more efficient ?
Here is my code that I used to get Image Size in Server:
public static Size GetImageDimension(string absolutePath)
{
byte[] imageData = File.ReadAllBytes(absolutePath);
var fullSizeImageHeight = -1;
var fullSizeImageWidth = -1;
MemoryStream origStream = null;
System.Drawing.Image fullSizeImg;
try
{
origStream = new MemoryStream(imageData);
fullSizeImg = System.Drawing.Image.FromStream(origStream);
fullSizeImageHeight = fullSizeImg.Height;
fullSizeImageWidth = fullSizeImg.Width;
}
catch
{
}
finally
{
if (origStream != null)
origStream.Dispose();
}
return new Size(fullSizeImageWidth, fullSizeImageHeight);
}
|
|
|
|
|
In my opinion, calculating the image dimensions on server side means doing I/O operations for each image request, so its better we ask individual client (i.e. browser) to do that. In that case your web server will not have that much load but yeah the browser may take some more seconds.
If you are not criticized, you may not be doing much.
'Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.' Robert Heinlein (1907 - 1988)
|
|
|
|
|
Hi,
Thanks for your reply.
Actually I am concerned about the overall speed,
So, let assume that, the time taken in server for FILE IO operation and image size calculation is = Ts
And the time taken in client for image size calculation on the fly is = Tc,
I need to know, if Ts > Tc or Ts < Tc.
If Ts < Tc, I will use server side code to calculate image size, I dont care about server load as the page I am rendering is a protetected page, only one user can see that page.
If Tc < Ts, then, I will let the browser calculate and display the page.
So, can you please tell me which value is higher ? Ts or Tc ?
It is very hard to experiment and find out these values, so I thought if this information is already known by others, it would be helpful.
Regards.
|
|
|
|
|
Hi,
I am fairly new to asp.net and need a bit of help please. In our project we are doing a callback from the client-side to the server side using a webmethod in order to try and keep the page request alive. From what I can see in Firebug is that, on the server side, the webmethod is triggered successfully from the javascript until I start with my async event on the server side, then the webmethod waits for it to be finished before the javascript calls the pagemethod again.
However this process of ours can take anything from 1 minute to 40 minutes, so it is quiet essential that I keep the page request alive. I don't want to increase the timeout on the scriptmanager since I don't think that is the right way to approach this issue.
Here is a small sample of how the code code is:
Java script:
function SimpleCallback() {
var lCurrentStatus = PageMethods.GetCurrentStatus(ProcessResults);
}
function ProcessResults(pCurrentStatus) {
if (pCurrentStatus != "Completed") {
window.setTimeout("SimpleCallback()", 100);
}
}
function SaveButtonClick(pArgument) {
var lAjaxManager = $find("<%= MyAjaxManager.ClientId %>");
lAjaxManager.ajaxRequest(pArgument);
SimpleCallback();
}
<asp:Button ID="SaveButton" runat="server" Text="Save" OnClientClick="return SaveButtonClick('SaveStuff');"
Server side code:
[WebMethod]
public static string GetCurrentStatus()
{
return FCurrentStatus;
}
protected void MyAjaxManager_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
if (e.Argument == "SaveStuff")
{
FCurrentStatus = "ProcessRunning";
SaveInformation();
}
}
delegate void MyLongRunningProcess();
private void SaveInformation()
{
var lLongRunningMethod = new MyLongRunningProcess(NextClass.Save());
IAsyncResult lResult = lLongRunningMethod.BeginInvoke(null, null);
while (!lResult.IsCompleted)
{
}
lLongRunningMethod.EndInvoke(lResult);
}
Is there a way of doing the pagemethod call from javascript asynchronously, since it seems this is my problem. Or is there another way of approaching this in order to keep the page request alive?
Thank you in advance,
David.
|
|
|
|
|
Calling the pagemethod is essentially asynchronous since it is out of band and the user can continue to interact with the page.
Typically one places some type of progress indicator on the page while waiting for the out of band call to complete. Look here[^] for an idea
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
40 minutes?! Surely you don't expect the user to hang around while that happens...? It doens't matter what code you use if they simply shut their computer down...
..on the assumption that all that matters is that your long running process is initiated by them, but they don;t need to wait for the result (you could always show it to them next time they log on), then you can accomplish this by calling a new HttpWebRequest, whcih will run in a new thread and won't be affected by what the user does once it is invoked. You will, by the sound of it, need to set/increase the ScriptTimeout property of your long running process.
Place your long running process in a generivc handler ("longrunning.ashx"), then call this from your server-side code as follows:
Dim rq As System.Net.HttpWebRequest = DirectCast(System.Net.WebRequest.Create("longrunning.ashx"), System.Net.HttpWebRequest)
rq.Method = "POST"
rq.ContentType = "application/x-www-form-urlencoded"
Dim postData As String = "" ' any data that needs to be passed to the handler
rq.ContentLength = postData.Length
Dim writer As New System.IO.StreamWriter(rq.GetRequestStream(), System.Text.Encoding.ASCII)
writer.Write(postData)
writer.Close()
Note that you should specify the full URL (http path) to "longrunning.ashx", not just the handler filename as I have above.
I can only giove you VB code for this I'm afraid - after that you;re on your own...
|
|
|
|
|
I want to place news and highlights and articles links on my website so I find or receive any interesting news or article I will put the title and url on my website.
I first thought to have a form to post it with txtTitle and txtURL textbox but then I had another idea and I want your advise please
I will create an email account then send the article title to that email address with article title in subject and article url in body
This will be easier to post especially when posting from mobile device
What do you think?
Also how can read the article title and url once received in inbox and save it into sql server article_title and article_url fields?
|
|
|
|
|
I have a main_menu.ascx web control placed in my root and contains my website navigation menu with NavigationURL to the pages
I have my root files and I included the ascx file there
Until here, I have no issue
Now!
I have sub folders in my root and I want to include same ascx file because I don't want more than one main_menu file!
But the problem here is with the NavigationURL because it will be different when the aspx file is in sub folder
How can make sure my NavigationURL is referring to the correct path whether aspx in root or in sub folder?
|
|
|
|
|
Why not use a masterpage? Also, you don't need to have multiple user controls that do the same thing, just change the data that is used to construct/populate it
I know the language. I've read a book. - _Madmatt
|
|
|
|
|