|
Hey guys, whats up ?
I want to connect to SQL in ASP.NET
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MyDB.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
In my main form I have this code:
I have added a SQLDatasource for my connection string !
MyConn.ConnectionString = SqlDataSource1.ConnectionString;<br />
MyConn.Open();<br />
MyCmd.CommandText = "SELECT UserName from UserT where UserName = " + UserName_tb.Text;
string CheckName = (string)MyCmd.ExecuteScalar();
in this line I get this error !
ExecuteScalar: Connection property has not been initialized.
|
|
|
|
|
The error is self explanatory.
You havent set the connection property for "MyCmd" i.e. sqlCommand.
Not very sure about VB syntax, but you need to do something like.
"MyCmd.Connection = MyConn "
It shud solve problem.
|
|
|
|
|
Thanx dude ! you ve been very helpful !
Mr.K
|
|
|
|
|
Most welcome Mr K.
Since am quite new to scores here.. wud really appreciate if you grade my reply and articles.
|
|
|
|
|
I have made a user control ( text.ascx) with a text box (txtUserControl) and a button (btnUserControl) .
<br />
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="test.ascx.cs" Inherits="WebApplication1.test" %><br />
<br />
<asp:TextBox ID="txtUserControl" runat="server"></asp:TextBox><br />
<br />
<asp:Button ID="btnUserControl" runat="server" Text="Button" /><br />
<br />
Now i load this usercontrol dynamically on (default.aspx) into two panels:
<br />
public partial class _Default : System.Web.UI.Page<br />
{<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
test tst = Page.LoadControl(@"~\test.ascx") as test;<br />
pnlDefaultOne.Controls.Add(tst);<br />
}<br />
<br />
protected void btnDefault_Click(object sender, EventArgs e)<br />
{<br />
test tst = Page.LoadControl(@"~\test.ascx") as test;<br />
pnlDefaultTwo.Controls.Add(tst);<br />
}<br />
}<br />
Now, the question is about the beahviour of textbox (txtUserControl), and its viewstate.
When i click btnDefault.. it loads the userControl in panelTwo.
now when i enter values in both the textboxes (each of a usercontrol), and click the btnDefault, the value in the first control (the one loaded at page_load) is persisted, while in the other one which was loaded in btnEvent is NOT.
i have read decent enough abt page cycle and am aware abt rendering, viewstate, postBackData.
BUt cant really figure out the reason behind this.
Any comment on the same will be of help.
Thanks in advance.
|
|
|
|
|
Good day my friends.
I am having a few issues with dates. It's like this.
Textbox auto populates on page load with todays date in english format (day/month/year).
Then when I go to use this and stuff it in the database I get an error, pretty much cos the date is in the wrong format.
So I added in the code to alter this to the correct (American) format for the db. This worked fine until code was passed over to my web server and then it stopped being happy about the format of the date from the text box.
How do I get around this issue without getting to complex. Code is as follows
<br />
Dim ExpiryDate As String = Convert.ToDateTime(ExpiryDateTB.Text.Trim()).ToString("MM/dd/yyyy")<br />
|
|
|
|
|
When updating the database do as follows I'm a C# guy but here is close to what you should do.
Dim datetime d;
if datetiem.tryparse(this.ExpiryDateTB.Text, out d) = true
sqlparameter prm = new sqlparameter("@yourParam", d)
do updates.
I didn't get any requirements for the signature
|
|
|
|
|
Use a UTC format to store your datetime. That way you eliminate the differences in culture.
Also, I think you could choose a more appropriate subject than, God dam dates!! It's offensive and does not follow the guidelines. See How to get answers post at the top.
only two letters away from being an asset
|
|
|
|
|
Hi All,
I have developed a web application using C#.NET and ASP.NET
I have uploaded web Application to our Server.The Url is http://www.xtravels.com .We can access this url from outside.But the problem is We can not access this from inside the Server.
Can any tell me how to fix that problem. I have tried it to solve. But can't.
Thanks in advance.
|
|
|
|
|
pubududilena wrote: I have uploaded web Application to our Server.The Url is http://www.xtravels.com .We can access this url from outside.But the problem is We can not access this from inside the Server.
oh. inside the Server?? How did you go inside the Server? I guess your server might be really large so people can go inside the System Unit.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Just try the local IP of the server machine.
|
|
|
|
|
Hi,
Internect connection is working properly in the server. So we can remotely log on to there.But When I brouse http://www.xtravels.com inside the server,I am unable to brouse the site and said "Page can not be displayed".
any idea to solve this prob?.
|
|
|
|
|
hi all...i am making one ajax enabled website using microsoft ajax extension 1.0 and asp.net 2.0. i am sending my code in which i am facing problem.
===========================================================================
1) masterpage:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage2.master.cs"
Inherits="MasterPage" %>
<title>Untitled Page
// some ajax related tags like script manager etc. <asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
2) page which is making problem
<%@ Page Language="C#" MasterPageFile="~/MasterPage2.master" AutoEventWireup="true"
CodeFile="GetClient.aspx.cs" Inherits="GetClient" Title="Untitled Page" %>
<asp:content id="Content1" contentplaceholderid="ContentPlaceHolder1" runat="Server">
<asp:textbox id="txtClientNo" runat="server" size="20" autopostback="true" enableviewstate="true" onchange="return getClient();" ontextchanged="txtClientNo_TextChanged">
3) code behind:
// namespace
// namespace
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
Response.Redirect("somepage.aspx"); // some page is my another page
}
}
4) java script file:
function getClient()
{
alert("function working fine ");
return true; or return false // as tried with both
}
now my problem is that when i am entering any data in my textbox in my page GetClient.aspx then onchange event is firing and getCLient function is working fine, but independent to what i am returning from the javascript function either true or false, page is behaving in this way: below mentioned:-
in my textbox if i am using onchange="return getClient();" then always it is not firing server side, but if i am using onchange="getClient();" then it is firing server side always. what is wrong here?...
<asp:textbox id="txtClientNo" runat="server" readonly="true" size="20" autopostback="true" enableviewstate="true" onchange="return getClient();" ontextchanged="txtClientNo_TextChanged">
plz let me know if anyone knows solution to fire servber side based on true or false returned from client side function...
-- modified at 11:05 Thursday 16th August, 2007
Akhilesh Singh
|
|
|
|
|
Do return false; and your page won't post back.
I didn't get any requirements for the signature
|
|
|
|
|
Thanks for reply ToddHileHoffer. i have tried returning false but independent of what i return either true or false, it always depending on how i am calling my java script function means:
if i will use: onchange="return getClient();" then it is not firing server side
but if i use: onchange="getClient();" then always firing server side.
in both condition it is not depending on what i am returning from my function getClient(), true or false.
is there any diference in working of this return true or false mechanism to stop or to run server side while working ajax enabled site as compared to normal website.
Plz reply if you have any idea about this?
Akhilesh Singh
|
|
|
|
|
Hello Everyone,
I want to send the coding using the given below coding But i'm getting the error
"Could not access 'CDO.Message' object."
Plz suggest me the ways to come out of the problem
MailMessage mail =new MailMessage();
mail.To="manoj.msb1984@gmail.com";
mail.From="mail@saamstesting.com";
mail.Subject="Your Password";
mail.Priority = MailPriority.Normal;
mail.Body="This is Ur Password";
try
{
SmtpMail.SmtpServer="mail.saamstesting.com";
SmtpMail.Send(mail);
lblMsg1.Text="Mail Sent Successfully";
}
catch(Exception ex)
{
lblMsg1.Text=ex.Message.ToString();
lblMsg1.ForeColor=Color.Red;
}
|
|
|
|
|
(1) Specify a valid mail server for the SmtpMail.SmtpServer property. If that property is not set, at least set it to 127.0.0.1. For example:
SmtpMail.SmtpServer = "127.0.0.1".
(2)If you are using "localhost" or "127.0.0.1" as the SmtpMail.SmtpServer, you may not have permissions to relay through the IIS SMTP Service. To allow access, open up the IIS Admin MMC. Locate the SMTP Virtual Server, and right-click, then select Properties. On the Access tab, click the Relay button. In the Relay Restrictions dialog, grant your IP address (127.0.0.1) to the Computers listbox. Close down all dialogs, and restart the SMTP Service.
Hope this could solve your problem.
SSK.
|
|
|
|
|
Hello Sir,
I've done as u r asking but using this way i'm getting successful message but not receiving the email at my gmail Account.
my Smtp Server="mail.saamstesting.com";
plz suggest some other way .........
one more thing whenever i'm trying to send the email at my "mail@saamstesing.com" then i'm receiving the mails but i'm not able to send the emails in ASP.NET
plz................. it's very urgent
|
|
|
|
|
|
There exist several problems and solutions.
Ever thought of trying Google? Google results
At least you should provide information about what you have already tried.
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
"Plz it's very urgent" isn't a very good subject line and gets ignored by those who can help the most.
only two letters away from being an asset
|
|
|
|
|
i am sending mail using arabic texts ..
My code is below
help me plz.. advance thanks to all
Dim MailApp As New MailMessage
MailApp.Body ="Arabic Texts"
MailApp.BodyEncoding = MailApp.BodyEncoding.UTF8
when recieving the mail through yahoo account it shows only ??? marks..
but in gmail it shows right texts..
help me plz....
advance thanks...
|
|
|
|
|
Did you check your Unicode?
SSK.
|
|
|
|
|
thanks for reply.
This is my code simply.
Dim MailApp As New MailMessage
MailApp.Body ="Arabic Texts"
MailApp.BodyEncoding = MailApp.BodyEncoding.UTF8
it shows the right chars in gmail but ??? marks in yahoo account.
|
|
|
|
|
Hi,
This is from Chandrakanth. I am using GridView Control. And I would like
to update the records through Coding. Can any one tell me how to go for
that.
Thansk in Advance
With Regards
Chandrakanth
Chandrakanth
Chandrakanth
|
|
|
|