|
hi try to add parameters in the following way
Emp.Parameters.Add(New System.Data.Odbc.OdbcParameter("@EventType", System.Data.Odbc.OdbcType.Int));
Emp.Parameters("@EventType").Value = EventType;
Emp.Parameters.Add(New System.Data.Odbc.OdbcParameter("@EventTime",System.Data.Odbc.OdbcType.DateTime));
Emp.Parameters("@EventTime").Value = EventDateTime;
Emp.Parameters.Add(New System.Data.Odbc.OdbcParameter("@Vehi", System.Data.Odbc.OdbcType.VarChar, 100));
Emp.Parameters("@Vehi").Value = Vehicle;
Emp.ExecuteNonQuery();
|
|
|
|
|
thanks for ur reply ..
i tired the code.
but still am getting the same error.
ExceptionSystem.Data.Odbc.OdbcException: ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure or function 'INSRTEVNT' expects parameter '@EventType', which was not supplied.
plz give me suggestions
cheers
sangeet
|
|
|
|
|
I am using a text box within the update panel - context
But, I am not being able to validate it using the regularexpression validator.
any Ideas ?
Thank you
|
|
|
|
|
Hello There again i guess, can you help me w/ this.i look for some example of validating a username and password in a
database on the internet..well looking for some tutorial instead,i found one and copy it, i follow the instruction, but i
dont get it..maybe im a slowlearner,there are instrcution that i dont get it..
here are the instructions
Pre-Code Setup:
1. Create a New ASP.NET Web Application. I called mine NorthLogin2
2. Rename the default aspx Webform to Login or Index or something more descriptive. I called mine Login2.aspx
3. Assuming you are in Visual Studio.Net right click on this form in the Solution Explorer and Select Set as Start Page.
4. Find your Northwind.mdb file (The classic Northwind Database in Access)
Under Tools, Options, Tables/Queries Tab select Run Permissions as Owner's
5. Create a new table for login requirements. I called mine tblUser
Columns U_id (autonumber), U_Name (text), and U_Password (text with Input Mask of Password)
6. Create Query (i.e. Stored Procedure) to validate login(s). I called mine sp_ValidateUser
In the SQL Designview the code for that query is
SELECT COUNT(*) AS Num_of_User
FROM tblUser
WHERE (((tblUser.U_Name)=[@UserName]) AND ((tblUser.U_Password)=[@Password]));
This query counts the number of users that it retrieves which matches the where clause. The @UserName and @Password are the
values passed in to the query from the Webform.
7. Close database, because you can not access it while it is open.
-----------END
--->in the ff. instruction i already done the instruction # 1-5..im confused about #6..would you help me with that..coz
there are no instruction, i dont know how to put COUNT* on the query at MS ACcess,i tried to create in a "Create Query in
Design View" but where should i found COUNT(*)??im not that expert in MS Access and SQL..
-->what does API mean?.
-->well theres another one...along with the tutorial is said that "This is sample code for a ASP.Net Login page (using Visual
Basic.Net code behind) with OleDB connection to an Access Database using ADO.Net."..it means whenevr you bulid or creating
asp.net with database access does it means that im also creating a Access database at ADO.net??
-->ok here is another one(sorry if im going to ask all the confusing question inside my head)..im also want to create a
"Forum" web application that i will include in our website project...our team leader(only at our project)also my classm8 said
that i have to used a "control panel" to done it..i dont know what she means??would someone give me an idea what "Control
Panel" is or a hint to start a 'FOrum Web Application" or what shoud the best web control to used in this application..
-->if i will ask my team leader to explain it to me well she will get angry if she found out that in our project there are
still no development that im trying to connect to the database, also trying to figure out how to validate password and
username name in a database(well to tell you that in our group,im responsible in coding asp,net)..
-->for those who always help me thank you..i know that im some kind of stupid, i may used my common sense,but i dont still
get it..Im just new at programming asp.net...
-->once again thank you for reading this thread..hope you can give me advice..becuase i dont know what to do..
Im tired thingking
|
|
|
|
|
write the sql query in your login page's code behind file, then use oledb to connect the access database and execute the query
|
|
|
|
|
Dear blitz2bleach,
1. Regarding your Count(*) problem : Just check your MS access editor or what you say MS access Quesry designer you can get the Count function somewhere in Function(s)
2. API is nothing but Application Programming Interface. Just method and properties of class that you can use while developing an appliation.
Thanks,
Arindam D Tewary
|
|
|
|
|
When I run my simple project, I am getting this message below.
"The report you requested requires further information."
What does it mean? If you know, please share it with me!!!
Keep battling!
|
|
|
|
|
I think ur connecting 2 two tables and display the o/p,
so,regarding that,u need some other field also want to tell in that display query...,
Magesh
|
|
|
|
|
1st post so go easy!
coding: aspx web pages in vb.net 2.0
database: sql server express
i would like to set session variable values from a database query and i cant find out how to do it!
the page flow would be something like this:
1) query database using 'SELECT userID, firstName, lastName FROM users WHERE userID = 1'
2) if data is returned:
create userID, firstName and lastName sessions from the database values for those columns.
3) if no data is returned
tell the user an error has occurred.
4) finally display the session values or the error message on the page.
i can find thousands of tutorials on how to bind data to controls (GridView, DataList, Repeater etc) but none telling me how to query the database and set sessions, cookies or page variables...
if anyone can shed some light on this, it'd be great!
thanks out there,
jake
|
|
|
|
|
i've made a bit of progress with this problem.
this works, but i'm *pretty* sure that it's not the right way to do it.
this code 'loops' through all the database returns but in my example, there should be only one row returned.
i also cant figure out how to do a (this is in english not code):
if (dataSet is empty) Then<br />
<br />
set a error message<br />
<br />
Else<br />
<br />
create the sessions<br />
<br />
End If
hmmm, tricky.
this is the code i've put together:
Dim conn As SqlConnection = [con string here]<br />
Dim dsProjects As DataSet = New DataSet()<br />
Dim cmd As SqlDataAdapter = New SqlDataAdapter("SELECT userID, firstName, lastName FROM users WHERE userID = 1", conn)<br />
<br />
cmd.Fill(dsProjects, "tblProjects")<br />
<br />
Dim dr As DataRow<br />
Dim dt As DataTable = dsProjects.Tables("tblProjects")<br />
<br />
For Each dr In dt.Rows<br />
<br />
Session("clientID") = dr("clientID")<br />
Session("clientID") = dr("firstName")<br />
Session("clientID") = dr("lastName")<br />
<br />
Next
what do you reckon out there? am i going about this the right or wrong way?!
cheers,
jake
|
|
|
|
|
That's pretty much how I'd do it too, with a couple of points to note...
Firstly, I tend not to use raw SQL in my code, for a variety of reasons....I would use a stored proc in the DB to get the data using a sqlCommand Object
Secondly, theere seems to be a little bit of redundency going on - instead of....
Dim dr As DataRow
Dim dt As DataTable = dsProjects.Tables("tblProjects")
For Each dr In dt.Rows
Session("clientID") = dr("clientID")
Session("clientID") = dr("firstName")
Session("clientID") = dr("lastName")
Next
you know that you're only going to return 1 or zero rows, so the loop is not necessary....so it would become
Dim dr As DataRow
Dim dt As DataTable = dsProjects.Tables("tblProjects")
dr = dt.Rows[0]
Session("clientID") = dr("clientID")
Session("clientID") = dr("firstName")
Session("clientID") = dr("lastName")
which could be further simplified to...
Session("clientId") = dt.Rows[0]["clientId"]
Session("firstName") = dt.Rows[0]["firstName"]
Session("lastName") = dt.Rows[0]["lastName"]
Another alternative would be to take advantage of the fact that session stores objects just fine - so if you wanted to, you could store the DataRow itself, and pull the values out when needed using somehting like :
Session ["theDataRow"] = myDataRow;
.
.
.
DataRow dr = (DataRow)Session["theDataRow"];
it's swings and roundabouts really!
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
hi richard,
thank you for your post, it's really helped me out! as you say, it's swings and roundabouts; there's never a '100% this is the only way you do it' solution with programming and it's always good to get a 2nd opinion to make sure your heading in the right direction.
i agree with using stored procedures instead of inline sql but for forum posts, i usually type it out to avoid confusion with column names etc (also handy when someone spots a blunder in the sql!).
everything is now working, the only thing i've left to solve is this:
i currently show the session values back to the page in text box's. as all my asp code in a 'code behind' file, i can response.write a message (or bind it to a label) back if no data is returned sort of like this:
If (dt.Rows.Count = 0) Then
Response.Write("no data returned")
End If
but what i cant figure out is how to not show the text boxs on the page, just the message? i know i could do the same if statement on the page, but that means not using the code behind file which i'm very keen on.
back to google for a bit me thinks!
thanks again for your help,
jake
|
|
|
|
|
I think I get what you mean...
The usual way that I show and hide different content is by using divs. If I follow you correctly, I'd set my page up something like
<table>
<tr>
<td>
<div id="divSuccess" style="width:100%; height:100%; display:none">
<asp:TextBox.........>
<asp:TextBox.........>
</div>
<div id="difFailure" style="width:100%; height:100%; display:none">
<asp:label...........>
</div>
</td>
</tr>
</table>
Then I'd use client scripting and document.getElementById() to set the display to "inline" for the div I wanted to show. If you were determined to do something on the server side, then you could either add a runat=server to the divs and manipulate their styles, or alternatively (and IIRC) an <asp:panel> exposes a Visible property, and renders as a div anyway
If you wanted a simpler method, you could of course just manipulate the visible property of the label and textboxes directly - I just like doing it with divs to keep the markup nice and clear, and so that if you encounter a divSuccess.style.display = 'inline' then it's easier to get what's going on quickly.
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
hi richard,
wow, thanks for the reply! finally feeling like i'm getting somewhere with the beast that is asp.net!
the funny thing is it's beginning to remind me of the flash actionscripting i did a while back... interesting.
taking your advice with the div thing to show success/failure i've put the code together as a 'finished' product.
there's some area's i'm still unsure about:
1) cant figure out why i have to create a 'SqlDataAdapter' and then a 'DataTable' and then fill them respectively - the whole thing seems a bit long winded!
2) idealy i would like to show the returned data back to the page without using labels as they create additional code i dont need. for example, the 1st label returns as:
userID = <span id="lblUserID">1</span>
and i dont need the span! not sure how to get round that one...
3) tidying up the objects at the end of the script - which do i need to do?! at the moment, i have this:
dsUsers.Dispose()
dsUsers.Dispose()
myAdapter.Dispose()
dt.Dispose()
conn.Close()
do i need to do it?!
that aside, here's the front end code (had to put on my site as it's too long for the forum):
SettingSessionsFromDatabaseQuery.aspx
and this is the code behind file:
SettingSessionsFromDatabaseQuery.aspx.vb
watcha reckon? any improvements?!
thanks again for all your advice,
jake
|
|
|
|
|
I'm looking for help on my CMS (Sprocket) which I believe is significantly architecturally superior to the god-awful mess that is DotNetNuke. DNN is basically the only major open source CMS for the .Net community (unless you count Rainbow which is basically the C# version of it). There are others, but the only ones I have found are either very simple, have mountains of sprawling ASPX/ASCX clutter to try and maintain, and/or are trying to be another 3-column portal engine (like we don't have enough of those).
Clocking in at over 23,000 lines of code so far, Sprocket boasts features such as a completely free-form templating system that borrows inheritance and polymorphism concepts for extreme versatility, in-built english-language-readable scripting language that can be used anywhere, e.g. in the templates, content, or wherever, friendly URLs, a full AJAX framework, and a bunch of other stuff too.
The CMS is built using C# and ASP.Net 2.0 but WITHOUT all those nasty aspx pages and ascx controls. In fact, there are no ASPX/ASCX files to be found anywhere, as the whole system has been built to bypass that messy stuff and work in a much more unified fashion.
Take a look at www.sprocketcms.com[^] (redirects to the google project hosting site) for a complete feature list and to get access to the open source (BSD license) code base for review. There are several sites running it so far and more in development, but the code base has been 100% written by me and some help would be greatly appreciated to help accelerate things to the point where it can start to be viable competition to DNN.
NATHAN RIDLEY
Web Application Developer
email: snowdevil [@] gmail.com
web/blog: www.sprocketcms.com[ ^]
|
|
|
|
|
So, I have vs2005 on Vista, and trying to make a website. Start a new project, select HTTP, type in the URL to my server (for now, running Windows 2003 inside a VMWare machine, but will get a new machine later). VS asks me for login credentials, I supply those of an admin (not administrator, but my user that has admin rights) on the W2k3 machine, and the projects gets copeid over fine. Now,when I try to debug it from vs2005, it can't. I'm getting all sorts of bizarre erors. If on my vista machine im logged in as a power user, then i am told that remote debuggins tools are not running on W2k3 (they are, I installed it and started it). If running as user with admin priveleges on vista machine, i am told "access denied". In both cases, I _am_ asked for login credentials and suply those of admin user on W2k3 machine.
I guess I should also add that there is no domain controller here, so each machine has its own credentials.
Now, has anyone had this kind of thing happen to them? How do I battle this? Its not exactly fun having to debug on the builtin asp.net server of vs2005, then copy files over to W2k3 machine and find out it doesnt work on IIS due to different permissions.
Thanks in advance.
|
|
|
|
|
This[^] post has some tips that you may find useful.
From the above link: If you are debugging from a remote machine, you will need to run the Visual Studio Debugging Monitor on the remote machine, and open the firewall so that Visual Studio can connect to the debugger (msvsmon.exe does this for you by default).
Hope that's of use.
|
|
|
|
|
thanks, I'll look into it. though i am running iis in w2k3 server, but should still help. cant check now as I'm on a diferent machine.
|
|
|
|
|
Hi,
I have a simple form with a textbox and a drop down list on it. I've used an ASP.NET (2.0) ddl control and an ASP.NET button for submitting the form. I have an event handler on the submit button, btnSubmit_Click() which triggers when the submit button is clicked.
When I try and access the ddl's value in the event handler, it's always set to the original value it was when the page was loaded. In other words, it ignores whatever the user changes it too before clicking "Submit".
Here's my aspx:
<form id="frmTest" runat="server" action="test.aspx" method="post">
<asp:DropDownList ID="ddlColor" runat="server">
<asp:ListItem Value="Red">Red</asp:ListItem>
<asp:ListItem Value="Amber">Amber</asp:ListItem>
<asp:ListItem Value="Green">Green</asp:ListItem>
</asp:DropDownList>
<asp:button id="btnSubmit" text="Submit!" onClick="btnSubmit_Click" runat="server" />
</form>
Here's the code behind:
protected void btnSubmit_Click(object sender, EventArgs e)
{
String str = ddlColor.SelectedItem.Text;
}
Do I need to call anything to get the changed value of the DDL before I look at the <code>ddlColor.SelectedItem.Text</code> property?
|
|
|
|
|
Hi,
No need to call anything to get the changed value of the DDL.
|
|
|
|
|
Give if not page.ispostback then cmd....,
or change the auto postback properties in ddl,
Magesh
|
|
|
|
|
I have a data grid in ASP.NET 2.0 that contains the following fields:
ID
Task
Comments
User
The User field is populated with the login name of the user who created the item. How can I filter this dataset with a Page_Load event based upon the users login name?
GT
|
|
|
|
|
If you want to disply only a particular user's items only in the datagrid, you will have to create a different datasource for that. For example, if you are using dataset or datatable as datasource, you will have to create a dataview and filter the particular user id. Then bind the datagrid with the dataview as datasource
hope this will help
|
|
|
|
|
Hi,
Firstly You must have a dataset on your hand code behind.
You can write a method like this,
protected void Page_Load(object sender, EventArgs e)
{
if{!IsPostBack}
{
querystring = "Your query";
GetData(String queryString);
yourdatagrid.DataBind;
}
}
DataSet GetData(String queryString)
{
DataSet ds = new DataSet();
SqlDataAdapter adapter = new SqlDataAdapter(queryString, SqlConnection);
adapter.Fill(ds);
return ds;
}
I hope I understand you correctly.
|
|
|
|
|
Well let me see if I can explain a little better.
I want to somehow take the current users login name and filter a table with that string.
GT
|
|
|
|
|