|
asad_black wrote: Dim query As String
query = "Select Count(*) From login Where username = ? "
Dim result As Integer = 0
If result > 0 Then
Well, there's a pretty good start. You've defined a query and then you don't use it anywhere. You initialise result to 0, and then test to see if result is greater than zero. Are you seeing the problems with that?
asad_black wrote: Dim strSQL As String = "INSERT INTO login (username, [password]) " & _
"VALUES (?, ?) "
Dim dbComm As New OleDbCommand(strSQL, objConnection)
dbComm.Parameters.Add("UserName", OleDbType.VarChar, 32, "UserName")
dbComm.Parameters.Add("Password", OleDbType.VarChar, 128, "Password")
Here you define your query with ? placeholders and then don't use them to when assigning your parameters. There are lots of things wrong here, and you should take the time to look into it.
|
|
|
|
|
asad_black wrote: If result > 0 Then
I think if you will modify your condition mentioned above to:
If result = 0 Then
then it will work.
|
|
|
|
|
I have an ASP.NET applications (using VB.Net code) having 2 webforms and it loads couple of Crystal Reports each time depending upon selections.
my execution path is as follows :
http://localhost/webApps/PIN/WebForm2.aspx (it loads this page correctly)
"WebForm2.aspx" is having some selection criterias for the report to be loaded. But when this page loads I get an CrystalReportViewer message on top left corner of the page which is as follows:
CrystalReportViewer - CrystalReportViewer1<br />
Use ReportSource or DataBindings property to specify a report source.
Also, in "WebForm1.aspx", I've got the following - OdbcSelectCommand, OdbcDataAdapter, OdbcConnection. And when I click on the "Command Text" property of "OdbcSelectCommand" which is infact an SQL query, I get this error messsage too : " [S1000] [IBM] [Client Access Express ODBC Driver (32-bit)] Syntax error in Connection String"
This is the connection string that I'm using :
Me.OdbcConnection1.ConnectionString = "DSN=as400;UID=pcain;PWD=marugo"
Please see the code below to see how Crystal Report is loaded :
Protected WithEvents active_referral1 As Crystal_dataset.active_referral
Protected WithEvents As400ds1 As crystal_dataset.as400ds
Me.OdbcSelectCommand1.Connection = Me.OdbcConnection1
Me.OdbcConnection1.ConnectionString = "DSN=as400;UID=pcain;PWD=marugo"
OdbcDataAdapter1.Fill(As400ds1)
If Report_Type = 3 Then
active_referral1.SetDataSource(As400ds1)
active_referral1.DataDefinition.FormulaFields("unboundstring3").Text = "'" & Fac_Str & "'"
active_referral1.DataDefinition.FormulaFields("unboundstring4").Text = "'" & Race_Str & "'"
active_referral1.DataDefinition.FormulaFields("unboundstring5").Text = "'" & Rel_Str & "'"
active_referral1.DataDefinition.FormulaFields("unboundstring6").Text = "'" & Sex_Str & "'"
active_referral1.DataDefinition.FormulaFields("unboundstring7").Text = "'" & Ref_Str & "'"
active_referral1.DataDefinition.FormulaFields("unboundstring8").Text = "'" & Sub_Str & "'"
active_referral1.DataDefinition.FormulaFields("unboundstring9").Text = "'" & Sub2_Str & "'"
If View_List = 1 Then
CrystalReportViewer1.ReportSource = active_referral1
ElseIf View_List = 2 Then
MyExportOptions.ExportFormatType = CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat
MyExportRequestContext.ExportInfo = MyExportOptions
MyStream = active_referral1.FormatEngine.ExportToStream(MyExportRequestContext)
Response.ClearHeaders()
Response.ClearContent()
Response.ContentType = "application/pdf"
Dim MyBuffer(MyStream.Length) As Byte
MyStream.Read(MyBuffer, 0, CType(MyStream.Length, Integer))
Response.BinaryWrite(MyBuffer)
Response.End()
End If
End If
Can anyone please give me any suggestions???
Thanks in anticipation.
|
|
|
|
|
Hi all,
I have a user control having a command button. On click of button, I've bound a javascript function which should show a div control. But, when I click on button, it postback the page.
cmdPostComment.Attributes.Add("onClick", "return showDiv();")
function showDiv()
{
document.getElementById("divPostComment_Tab1").style.display = "block";
return false;
}
I've noticed one thing, When page renders, command buttons name got changed to "control1$cmdPostComment".
Thanks in advance.
|
|
|
|
|
Add it as OnClientClick in your aspx page. That should work.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
|
Do you have auto postback turned on ? I do this all the time and it works fine, set the OnClientClick, return false from it, and the Onclick will not run.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Neeraj Arora wrote: document.getElementById("divPostComment_Tab1").style.display = "block";
Check the ID of "divPostComment_Tab1" after rendering of the page and use that ID instead of "divPostComment_Tab1".
|
|
|
|
|
I'm adding a list of GridTab user controls to a container TabControl. Each GridTab contains only one GridView control, and my problem is that when the GridTab fires Page_Load, its GridView hasn't been instantiated yet.
I could do this in the GridTab constructor, but would really like to know why the u/c isn't doing it in this case, when it does if I add the u/c manually.
|
|
|
|
|
Hello,
Please check this link http://msdn.microsoft.com/en-us/library/bb545450.aspx[^]">. I wonder how Microsoft did hide the verticall scrollbar of IE7. I also wonder how they kept the top of page static, so the scrollbar is under the static section.
If you enlighten me about it, I would appreciate.
Thanks.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
overflow-x:hidden
in your css.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Hi, I got the following code in my webservice. The code gets VARCHAR values from within a sql database:
[WebMethod]
public ArrayList GetUserInfo(string email)
{
ArrayList userInfo = null;
try
{
conn = new SqlConnection("User Id=sa;Password=myne;Initial Catalog=Bank;Data Source=myComp");
conn.Open();
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT mem_Name, mem_IdNum, mem_Email, mem_Address, mem_PhoneNumber, mem_Question, mem_Answer FROM Member WHERE mem_Email = '" + email + "'";
SqlDataReader reader = cmd.ExecuteReader();
reader.Read();
userInfo = new ArrayList();
userInfo.Add(reader[0].ToString());
userInfo.Add(reader[1].ToString());
userInfo.Add(reader[2].ToString());
userInfo.Add(reader[3].ToString());
userInfo.Add(reader[4].ToString());
userInfo.Add(reader[5].ToString());
userInfo.Add(reader[6].ToString());
conn.Close();
}
catch (SqlException sqlex)
{
}
finally
{
if (conn != null)
{
conn.Close();
}
}
return userInfo;
}//End GetUserInfo
I the call this method from an aspx web page, which looks like this:
void Page_Load(Object sender, EventArgs e)
{
if ((string)Session["email"] == null) //check if user logged in successfuly
{
Response.Redirect("login.aspx"); //if not got to login page
}
else
{
ArrayList myList = new ArrayList();
ServiceControl serCon = new ServiceControl(); //new instance of webservice class
string ed = (string)Session["email"]; //get the stored email from login
myList = serCon.GetUserInfo(ed); copy arrayList from webservice into new arraylist
}
}//End Page_Load
Everytime i'm redirected to the page, I get the following error on the following line of code:
myList = serCon.GetUserInfo(ed);
CS0029: Cannot implicitly convert type 'object[]' to 'System.Collections.ArrayList'
Do anyone know how I can fix this error please?
Iv'e tried adding .ToString(), iv'e tried casting to string, but with no luck.
|
|
|
|
|
Things wrong with this code:
sakkiedis wrote: WHERE mem_Email = '" + email + "'";
SQL injection. I can erase your DB any time I like
sakkiedis wrote: userInfo.Add(reader[0].ToString());
userInfo.Add(reader[1].ToString());
userInfo.Add(reader[2].ToString());
userInfo.Add(reader[3].ToString());
userInfo.Add(reader[4].ToString());
userInfo.Add(reader[5].ToString());
userInfo.Add(reader[6].ToString());
Code that assumes certain number of elements without checking
sakkiedis wrote: ArrayList userInfo = null;
Using the ArrayList class, unless this is 1.0 or 1.1.
sakkiedis wrote: if ((string)Session["email"] == null)
Not storing your session keys in a class, so they are subject to typos, etc. Does casting null to string work ? I'd generally wrap this behaviour in a base class.
sakkiedis wrote: ArrayList myList = new ArrayList();
creating an object that will never be used.
Does your method call execute ? Does it blow up trying to make the call, or within the call ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
just out of curiosity what would you recomend to replace the ArrayList class in later versions of .NET?
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
The List class, of course. The point is that it's type safe.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
but i so enjoy explaining to the new people why when they put a string in they dont get an int out. unfortunatly i'm not exaggerating.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
If you declare the web method to return an ArrayList, it will actually return an array.
If you want an ArrayList you either have to create one from the array, or serialise the ArrayList into a string and deserialize it on the receiving end.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I managed to fix the problem by just changing one line.
I did the following...
ArrayList myList = new ArrayList(serCon.GetUserInfo((string)Session["email"]))
Then to access a value in the array - Session["var"] = myList[0]
Thanx to everyone who replied and helped. Appreciate it...
|
|
|
|
|
return userInfo;
}//End GetUserInfo
I the call this method from an aspx web page, which looks like this:
void Page_Load(Object sender, EventArgs e)
{
if ((string)Session["email"] == null) //check if user logged in successfuly
{
Response.Redirect("login.aspx"); //if not got to login page
}
else
{
ArrayList myList = new ArrayList();
ServiceControl serCon = new ServiceControl(); //new instance of webservice class
string ed = (string)Session["email"]; //get the stored email from login
myList = serCon.GetUserInfo(ed); copy arrayList from webservice into new arraylist
}
Test Data
www.yahoo.com
fgff
|
|
|
|
|
|
Is viewstate turned on for the control and for the page ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
|
Hi ALL
I like to Show Computer name and IP and host name of the computer viewing the intranet web page on the page.
I am using aspx page with vb code behind.
I can only see the server`s hostname, ip address and hostname. not the current pc`s
Can someone help me PLEASE and can it be done?
|
|
|
|
|
You get the user IP address from Request.UserHostAddress .
As long as the compuer is in the same local network as the server, you can get the computer name using System.Net.Dns.GetHostEntry(ip).HostName .
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I tried that and it keep on giving me the server`s ip and host name.
Is it maybe a permission setting?
I have changed “authentication methods “to “integrated Windows authentication”.
Still not working.
I have also tried.
- My.Computer.name
- System.Environment.machineName
- Microsoft.VisualBasic.Interaction.Environ(“Computername”)
No Luck
|
|
|
|