|
Hey guys, Ive got a registration Page. There I ve got some fields and I want to
insert some data into database ! I've got everything set !
MyConn.ConnectionString = SqlDataSource1.ConnectionString.ToString();<br />
MyConn.Open();<br />
SqlCommand MyInsCmd = new SqlCommand();<br />
MyInsCmd.Connection = MyConn;<br />
<br />
MyInsCmd.CommandText = "INSERT INTO UserT (UserName, ...)VALUES (@UserNameP, ...)";<br />
SqlParameter UserNameP = new SqlParameter("@UserNameP", SqlDbType.NVarChar, 50);<br />
UserNameP.Value = UserName_tb.Text;<br />
MyInsCmd.ExecuteNonQuery();<br />
MyConn.Close();
but I get this error !
Exception Details: System.Data.SqlClient.SqlException: Must declare the scalar variable "@UserNameP".
I have declared it !!! I dunno why I get this error !
please help me out !
|
|
|
|
|
U have declare dthe parameter variable and assigned value for it
but u don't added it to the command object
MyConn.ConnectionString = SqlDataSource1.ConnectionString.ToString();
MyConn.Open();
SqlCommand MyInsCmd = new SqlCommand();
MyInsCmd.Connection = MyConn;
MyInsCmd.CommandText = "INSERT INTO UserT (UserName, ...)VALUES (@UserNameP, ...)";
SqlParameter UserNameP = new SqlParameter("@UserNameP", SqlDbType.NVarChar, 50);
UserNameP.Value = UserName_tb.Text;
MyInsCmd.Parametrs.Add(usernameP);
MyInsCmd.ExecuteNonQuery();
MyConn.Close();
this could help u....
|
|
|
|
|
|
Hi,
Just declare the variables for the Paramater values
eg. Sttring _UserName=String.Empty;
_UserName=txtUserName.Text.Trim();
...........
///Now Here write your CommandText Like this
MyInsCmd.CommandText = "INSERT INTO UserT (UserName, ...)VALUES (_UserName, ...)";
Or
///Write your CommandText directly with values
MyInsCmd.CommandText = "INSERT INTO UserT (UserName, ...)VALUES (Naresh, ...)";
Naresh Patel
|
|
|
|
|
There are multiple pages . On each page dynamic checkboxes. I check some checkboxes on first page i go to next page & check 2 more checkboxes . so when i return back to first page the checked checkboxes becomes unchecked. So how do i avoid this ?
with thanks and regards,
kaushik pulpa
|
|
|
|
|
Hi,
I am trying to access all controls of a page so that I can Check whether they are textboxex or radiobuttons.
I am trying the following code But I am unable to access these controls in a collection.
foreach(Control objcontrol in Page.Controls)
{
if (objcontrol is TextBox)
{
TextBox tx = (TextBox)objcontrol;
...
Can anyone suggest me proper to access all controls in a collection plz????
hiiiiii
|
|
|
|
|
Within "foreach" you can "access" all the controls.. but you can not change the state of objects within.
If that is the requirement, then you better access them usin "for" loop and access the controls using indexes.
In case, it doesnt answers your questions. PLease be more elaborate about the same.
Regards.
|
|
|
|
|
I have a Multiview with 3 view placed inside.
There is also a RadioButton List which cycles through the 3 different views,
When I select them
The radio button options will have
* View 1
* View 2
* View 3
I would like to know how to display all 3 view at the same time.
In this case i thought of having this option on the radiolist button
* View 1
* View 2
* View 3
* View All the above
|
|
|
|
|
Hi Guys need help....
I have a problem in downloading a create CSV file....
When i create the CSV in my folder is not an issue but after creating it and download to a location in other location the file show html of the aspx page not the original data that i create
Any one know what the problem? Please guide
KaKaShi HaTaKe
|
|
|
|
|
yes, the problem is in your code, obviously. How do you send it down ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Dim fileStream As New FileStream(fileName2, FileMode.OpenOrCreate)
'Dim bytes As Byte = New UTF8Encoding
Dim ExportedCSV(fileStream.Length) As Byte
'fs.Read(ExportedCSV, 0, fs.Length)
fileStream.Read(ExportedCSV, 0, fileStream.Length)
'fileContents = objstream.readtext
Response.AddHeader("Content-Disposition", "attachment;filename=" & fileName2)
Response.Charset = "UTF-8"
Response.ContentType = "application/csv"
Response.BinaryWrite(ExportedCSV)
'fileStream.Close()
this is the code i use
any issue with this code?
StreamWriter.Close()
KaKaShi HaTaKe
|
|
|
|
|
Hi,
I have a very interesting problem, my code doesn't show any errors or exceptions, but when I'm running the web-page, it still doesn't work properly. I want to bind an image on an image control, which is inside the Datalist and Datalist is inside the DetailsView. When I'm debugging the code, it shows me the imageURL path very well, but doesn't show me the image in the browser.
My Select statement si : SelectCommand="SELECT [Source] FROM [Images] WHERE ([NID] = @NID)
Here is my code on page load:
<br />
string nID = Request.QueryString["nID"].ToString();<br />
<br />
DataView view = (DataView)ImagesSqlDataSource.Select(DataSourceSelectArguments.Empty);<br />
int count = (int)view.Table.Rows.Count;<br />
Label username = (Label)NDetailsView.FindControl("UsernameLabel");<br />
DataList ImagesDataList = (DataList)NDetailsView.FindControl("ImagesDataList");<br />
<br />
for (int i = 0; i < count; i++)<br />
{<br />
Image image = (Image)ImagesDataList.Items[i].FindControl("ImageControl");<br />
string imagename = (string)view.Table.Rows[i].ItemArray[0];<br />
image.ImageUrl = Request.PhysicalApplicationPath + @"Images\" + username.Text + "\\" + nID + "\\" + imagename;<br />
<br />
}
Thank you
|
|
|
|
|
You are using Request.PhysicalApplicationPath which is not correct. This will translate to c:\inetputb\wwwroot or something like that.
Easiest way to fix the issue is:
image.ImageUrl = new StringBuilder(@"~/Images/").Append(username.Text)
.Append(nID).Append("/").Append(imagename).ToString();
|
|
|
|
|
Thank you!!!!!!!!!!!!!
|
|
|
|
|
We are a reseller for godaddy only for our email since we don't want to mess with email servers too much but we are having major support requests from our customers regarding their godaddy email - like people they send to not getting their email and such. Of course calling godaddy regarding this doesn't really help since they pretty much say it's our customers isp (which is just bull), but I would love to know if anyone else is having this problem and if so a solution? or if not an easy way to switch to someone else for our customers email accounts?
Free Hit Counter, Website Counters by The Hit Counters
http://www.thehitcounters.com
Custom Logo Design Services by http://www.thebusinesslogo.com
modified on Wednesday, May 6, 2009 6:09 AM
|
|
|
|
|
Hi - gone totally blank on this, up against the clock, and hoping somebody can patronisingly explain this...
I have a Button on a webpage, which when clicked, generates a word doc, via automation, and saves it to a share, and then 'should' call a client side script (to do some really secret stuff!). My code (C#) is similar to the following (which doesn't work):-
protected void OnGenerateDoc( object sender , EventArgs args )
{
MyDocGen gen = new MyDocGen();
gen.CreateDocAndSaveHere(@"\\publicserver\publicshare\wellknownfilename.doc");
(HttpContext.Current.CurrentHandler as Page).ClientScript.RegisterClientScriptBlock(this.GetType()
, "myScriptKey", "alert('your document is ready');" , true);
}
The alert command should be any javascript function that can be called. I just want it called when my stuff is complete. Any ideas? This is all in a custom control, in a DLL , hence the long winded way to get to the ClientScript. Is this the correct way of getting a reference to the page? Last modified: 1hr 21mins after originally posted --
|
|
|
|
|
Doesn't the last parameter, the actual javascript, have to be a full script block? ie, instead of just
alert('your document is ready');
you should create a string =
<script language=javascript>alert('your document is ready');</script>
and put that into the call
...
Fred
|
|
|
|
|
Hi
There is an overloaded call which takes a bool which adds the <Script> if you need it - I had missed this off the original (now amended) post. I've just tried wrapping the call as you suggested but still not a peep from the client.
I've put other debug code either side of the RegisterClientScript call which is being executed, so it's not bombing out there either. The client is just not getting the call.
|
|
|
|
|
I am trying to display markers held on a database on a google map, using VB.Net in aspx page. I am stuck with how to call the google map function from within the VB.Net code in the body of the aspx page. Can anyone help?
My code is:
<%@Import Namespace="System.Data" %>
<%@Import Namespace="System.Data.SqlClient" %>
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="mapmysql.aspx.vb" Inherits="mapmysql" %>
<title>Untitled Page
//<![CDATA[
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GScaleControl());
map.setCenter(new GLatLng(50.614, -3.591 ), 8);
// Creates a marker whose info window displays the given number
function createMarker(point, number)
{
var marker = new GMarker(point);
// Show this markers index in the info window when it is clicked
var html = number;
GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});
return marker;
};
//]]>
<% Dim conn As SqlConnection
conn = New SqlConnection("Data Source=beish2;Initial Catalog=HA4;Integrated Security=True")
conn.Open()
Dim sqlComm As New SqlCommand("SELECT PlaceID,PlaceName, PlaceLat, PlaceLng FROM Places ORDER BY PlaceName", conn)
Dim r As SqlDataReader = sqlComm.ExecuteReader()
While r.Read()
Dim username As String = CStr(r("PlaceName"))
Dim userID As Integer = CInt(r("PlaceID"))
Dim Lat As Double = CDbl(r("PlaceLat"))
Dim Lng As Double = CDbl(r("PlaceLng"))
****HOW TO CALL FUNCTION createMarker FROM HERE???? ****
Response.Write(Lat)
End While
r.Close()%>
|
|
|
|
|
|
Added this to try and re-centre map as test but nothing seems to happen - code must be in-correct but can't work out what is wronG. Anyone any ideas
Dim sb As StringBuilder = New StringBuilder
sb.Append("")
sb.Append("//<![CDATA[" & vbCrLf)
sb.Append("map.setCenter(new GLatLng(50.952803, -4.139785 ),9);")
sb.Append("//]]>")
sb.Append("")
ClientScript.RegisterClientScriptBlock(Me.GetType(), "sbf", sb.ToString())
|
|
|
|
|
I suspect you're going to have an order of operations problem here. When does this get called ? I'd say it probably gets called before your map is initialised.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
My complete code is below - I think the processes are in the correct order as the Response.Write(Lat) produces the latitude values from the database after the opening Google Map is displayed. If I move the map.addControl lines to the sb.append stringbuilder, they don't display - which would seem to indicate that the ClientScript.RegisterClientScriptBlock is incorrectly formatted, or the Stringbuilder. Not sure of what the "Type" is supposed to be or if the random name "sbf" I've given it should be something more specific.
<%@Import Namespace="System.Data" %>
<%@Import Namespace="System.Data.SqlClient" %>
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="mapmysql.aspx.vb" Inherits="mapmysql" %>
<title>Untitled Page
//<![CDATA[
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GScaleControl());
map.setCenter(new GLatLng(51.512161, -0.14110), 11);
// Creates a marker whose info window displays the given number
function createMarker(point, number)
{
var marker = new GMarker(point);
// Show this markers index in the info window when it is clicked
var html = number;
GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});
return marker;
};
//]]>
<% Dim conn As SqlConnection
conn = New SqlConnection("Data Source=beish2;Initial Catalog=HA4;Integrated Security=True")
conn.Open()
Dim sqlComm As New SqlCommand("SELECT PlaceID,PlaceName, PlaceLat, PlaceLng FROM Places ORDER BY PlaceName", conn)
Dim r As SqlDataReader = sqlComm.ExecuteReader()
While r.Read()
Dim username As String = CStr(r("PlaceName"))
Dim userID As Integer = CInt(r("PlaceID"))
Dim Lat As Double = CDbl(r("PlaceLat"))
Dim Lng As Double = CDbl(r("PlaceLng"))
Dim sb As StringBuilder = New StringBuilder
sb.Append("")
sb.Append("//<![CDATA[" & vbCrLf)
sb.Append("map.setCenter(new GLatLng(50.952803, -4.139785 ),9);")
sb.Append("//]]>")
sb.Append("")
ClientScript.RegisterClientScriptBlock(Me.GetType(), "sbf", sb.ToString())
Response.Write(Lat)
End While
r.Close()%>
|
|
|
|
|
Does the ClientScript.RegisterClientScriptBlock actually run the process or just "register" it for calling later?
|
|
|
|
|
Dear All,
I'm implementing a system add on using framework 1.1 and vb.net as a language
The requirement is to build "Outlook-Like" mailbox
I want to create three frames, left frame for the tree, top-right frame to display the incoming or outgoing messages, and bottom-right frame to display mail item content.
All that is doable but i guess my problems will start when i'm doing grouping, filtering, and changing icons for the tree items and same issues for the top-right frame. U know the group by sender,date,or flags
I want it to be fully customizable by the user.
So... What methods do u advice me to do,? what controls should i use (for the tree and grouper)? and what are the suggestions and advices that i need to know?
I would appreciate it alot
Best Regards
3ala2
|
|
|
|