|
Welcome Gaurav. Happy coding .!!
Vande Matharam - Jai Hind
|
|
|
|
|
Hi..I am currently working on a project on Library Management System. I ve created a database to store the books in the Library. While adding books, i want to add multiple copies of the same book. i need to create a unique book ID for each book..how can i make multiple entries of the same book wid different IDs for each?
eg., Book name: Engineering Thermodynamics
Author: P K Nag
Publisher: ABC
Edition: 2
Category: Mechanical Engineering
Quantity: 5
i need to add this data to the database making 5 different entries for the same book wid a unique ID. Plz help me!
|
|
|
|
|
You need two tables, one describing the book, and one for each copy. The latter references the former, using the ID of the book description table as a foreign key.
|
|
|
|
|
when i run like this :
testing.com/test.aspx?query=select top(60000) * from [dbo].tblTesting
the source is :
<pre lang="c#"><pre lang="c#"> <%@ Page Language="C#"%>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Web.Script.Serialization" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
using (SqlConnection cn = new SqlConnection("Data Source=127.22.125.11,1985;Initial Catalog=Test;uid=testing;pwd=123456"))
{
using (StreamReader sr = new StreamReader(Request.InputStream, Encoding.UTF8))
{
Response.ContentType = "text/plain";
string c;
c = Request.QueryString["query"]; //for debugging with the browser
//you can set the query by adding the query parameter For ex: http://127.0.0.1/test.aspx?query=select * from table1
if (c == null)
c = sr.ReadToEnd();
try
{
SqlCommand cmd = new SqlCommand(c, cn);
cn.Open();
SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
List<dictionary<string, object="">> list = new List<dictionary<string, object="">>();
while (rdr.Read())
{
Dictionary<string, object=""> d = new Dictionary<string, object="">(rdr.FieldCount);
for (int i = 0; i < rdr.FieldCount; i++)
{
d[rdr.GetName(i)] = rdr.GetValue(i);
}
list.Add(d);
}
JavaScriptSerializer j = new JavaScriptSerializer();
j.MaxJsonLength = Int64.MaxValue;
Response.Write(j.Serialize(list.ToArray()));
}
catch (Exception ex)
{
Response.TrySkipIisCustomErrors = true;
Response.StatusCode = 500;
Response.Write("Error occurred. Query=" + c + "\n");
Response.Write(ex.ToString());
}
Response.End();
}
}
}
</script>
the error is :
Error occurred. Query=select top(60000) * from [dbo].tblTesting<br />
System.InvalidOperationException: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.<br />
at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, StringBuilder output, SerializationFormat serializationFormat)<br />
at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, SerializationFormat serializationFormat)<br />
at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj)<br />
at ASP.test_aspx.Page_Load(Object sender, EventArgs e) in testing.com\test.aspx:line 44
|
|
|
|
|
jojoba2011 wrote: System.InvalidOperationException: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.
There is a limit on the max length of a JSON returned, you can adjust it in the web.config
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="50000000"/>
</webServices>
</scripting>
</system.web.extensions>
As for the reason for the super long JSON returned,
In my opinion, I would of created a web service, called test.asmx, and return a formatted JSON result, and then parsed it. But what do I know, I have no clue what your trying to do.
|
|
|
|
|
thanks a lot!
can give me a small example webservice json?
i am doing for mobile so when i press update button ,it should go to the main server and get all info (new and old and updated infos).
how to do that?
|
|
|
|
|
 I write in vb, not sure if that helps, but
<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
Public Function Get_RateVendorCode( _
ByVal rate_API_Code As String,
ByVal localization_Code As Integer) As String
Dim sb_json As StringBuilder = New StringBuilder
Dim json_response As String = Nothing
Dim Rate_VendorCode As String = ""
Dim service_Marks As String = ""
Dim service_Title As String = ""
Try
Dim rm As ResourceManager = Nothing
Dim ci As CultureInfo = Nothing
Select Case localization_Code
Case 0
rm = New ResourceManager("SC_Standard.labels_en", Assembly.GetExecutingAssembly())
ci = New CultureInfo("en-US")
Case 1
rm = New ResourceManager("SC_Standard.labels_fr", Assembly.GetExecutingAssembly())
ci = New CultureInfo("fr-CA")
Case 2
rm = New ResourceManager("SC_Standard.labels_es", Assembly.GetExecutingAssembly())
ci = New CultureInfo("es-MX")
End Select
Rate_VendorCode = Get_RateVendorCode_SQL(rate_API_Code)
Select Case Rate_VendorCode
Case "DHL"
service_Title = rm.GetString("Select Rate:")
service_Marks = rm.GetString("DHL service marks used by permission")
Case "FEDEX"
service_Title = rm.GetString("Select Rate:")
service_Marks = rm.GetString("FedEx service marks used by permission")
Case "FEDEXFREIGHT"
service_Title = rm.GetString("Select Rate:")
service_Marks = rm.GetString("FedEx service marks used by permission")
Case "UPS"
service_Title = rm.GetString("Select Rate:")
service_Marks = rm.GetString("UPS service marks used by permission")
Case "FREIGHTQUOTE"
service_Title = rm.GetString("Select Rate:")
service_Marks = rm.GetString("FreightQuote.Com service marks used by permission")
End Select
Catch ex As Exception
End Try
sb_json.Append("{")
sb_json.Append(" ""VendorCode"" : """ & Rate_VendorCode & """,")
sb_json.Append(" ""ServiceTitle"" : """ & service_Title & """,")
sb_json.Append(" ""ServiceMarks"" : """ & service_Marks & """")
sb_json.Append("}")
json_response = sb_json.ToString
Dim js As System.Web.Script.Serialization.JavaScriptSerializer = New System.Web.Script.Serialization.JavaScriptSerializer
js.Serialize(json_response)
js = Nothing
Return json_response
End Function
|
|
|
|
|
hopefully i am posting in the correct section.
I have created a class in c# to replace a vb6 class used in an asp web page. Note I said asp and not asp.NET. I am running this in IIS 7.5 on a 64 bit Windows 7 machine.
I compiled the program and all its support dlls as x86 and believe I got all the correct tags and check boxes for COM. I can create and use the class in VB6 but it still bombs in vbscript with can't create object. I found some articles on going to do tweaks in the registry to get it to work on 64 bit but alas no avail.
The web application will run with the old VB6 object just fine. The configuration is an application with a separate pool set to pipeline mode classic, no managed code, enable 32 bit applications = true;
Initially I was getting a can not create object when trying to use the new c# object but I copied the dll and its support dlls to the sysWOW64 directory and it changed it's tune to
MaxRecall.Shared error '80004003'
Object reference not set to an instance of an object.
/mr/mrq.asp, line 193
the structure of the project is thus
the object I am creating with createobject is dependent on a single assembly, MaxRecall.CORE, which is dependent on two assemblies, MaxRecall.CLIENTS and MaxRecall.Shared. None of the support assemblies are com exposed so this error is not a COM error at all I think.
MaxRecall.Shared is totally static with zero objects to create. It only had two static doubles that were class scoped that were not instantiated but I set them to 0 in their declarations. To my thinking there are no objects in MaxRecall.Shared to gain an instance to so the error is odd.
Sigh. Any and all insights are desperately welcomed. I cross posted this in the COM section.
|
|
|
|
|
notahack wrote: I cross posted this ... Please don't; see point 1 here[^].
Use the best guess
|
|
|
|
|
can anyone help me how to plug in facebook & twitter into the webapplication (c# asp.net4.0)...pls help me
|
|
|
|
|
|
https://developers.facebook.com/apps[^]
when i click the above link i am getting logon page,but not "create new app" button....pls could u tell me where it is...i am trying to identify for the past 3.30 hrs....but couldn't find....i am not getting clear picture....still trying to understand it...
Facebook: OAuth Dialog[^]
Using Web APIs with OAuth 2.0[^]
the above links....not able to understand...any help is appreciated...
same is d case with twitter
|
|
|
|
|
Member 8701813 wrote: when i click the above link i am getting logon page,
Login using your facebook account and see.
Member 8701813 wrote: the above links....not able to understand...any help is appreciated...
Article with code and sample were shared. If you are unable to understand it, it would be difficult for me to make you understand online. I would suggest you to catch someone in person - a senior or a teacher.
|
|
|
|
|
hi,
when i click on like button the count shold increase ...isn't it?but it is remaining same....
this is the code i added immediately below body tag
<div id="fb-root"></div>
<script> (function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=491658267536929";
fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'facebook-jssdk'));</script>
the follwing code after tag
<div class="fb-like" data-href=="<?php the_permalink(); ?>" data-send="true" data-width="450" data-show-faces="true"></div>
the following code in web.config
<appSettings>
<add key="EnableSqlDependency" value="true" />
<add key="ApplicationId" value="491658267536929" />
<add key="ApplicationUrl" value="http://localhost:1285/WebSite3/Default.aspx" />
<add key="ApiKey" value="" />
<add key="ApplicationSecret" value="506b293633ab728c0516359bce138953" />
<add key="ExtendedPermissions" value="offline_access" />
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
<appsettings>
<add key="EnableSqlDependency" value="true">
<add key="ApplicationId" value="491658267536929">
<add key="ApplicationUrl" value="http://localhost:1285/WebSite3/Default.aspx">
<add key="ApiKey" value="">
<add key="ApplicationSecret" value="506b293633ab728c0516359bce138953">
<add key="ExtendedPermissions" value="offline_access">
<startup>
<supportedruntime version="v4.0" sku=".NETFramework,Version=v4.0">
|
|
|
|
|
hi , they are creating new windows project & in that App.Config.But i created website & in that web.config....what should i do now could u tell me pls..
|
|
|
|
|
Error Message: Invalid length for a Base-64 char array.
Error Source: mscorlib
Target site: Byte[] FromBase64String(System.String)
Error StackTrace: at System.Convert.FromBase64String(String s) at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) at System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) at System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) at System.Web.UI.HiddenFieldPageStatePersister.Load()
Please help me to get of this error. I am getting lots of error on daily basis.
|
|
|
|
|
to help you with your error message we need to see a snippet of code where the error is happening. As the error on its own means very little expect what it has found.
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
What i think if any one post back the corrupted __viewstate data then this type of error can be regenerated.
|
|
|
|
|
Perhaps it's an encryption error.
It looks like you have an encrypted value in a query string or text box, and someone is injecting a bad value that doesn't match or use the proper cipher key, or is of a different length, and the error is not being caught.
I see that error when decrypting the wrong size ciphers.
|
|
|
|
|
What i observed by number of errors some one is changing the __viewstate and posting it back. Because at the time of error i am observing some kind of wrong string in __viewstate also they are trying to hack by passing same and invalid string combination in different input boxes.
Please let me know how can i stop hackers to do this?
|
|
|
|
|
I get about 30 hacks a day.
Usually a bad hyperlink injection into a textbox, to email bad websites and hack contact us pages, or bad url querystring to break the program.
All you can do is create a custom error page that redirects them, and fix the ones that you can fix with better error handling.
I don't know how to approach the viewstate issue, but you should probably google the viewstate hack.
|
|
|
|
|
|
can anyone help me how to rotate homepage banner upto 5 banner images in asp.net4.0(c#)
|
|
|
|
|
Please specify what problem have you encoutered. So far it is just keeping list of the images and showing them in sequence...
--
"My software never has bugs. It just develops random features."
|
|
|
|
|
i used adrotator....& 5 images...on page load these 5 images should be shown...could u suggest me any solution pls
|
|
|
|