ASP script - sql insert

Stephenz43

Member
Licensed User
Longtime User
I have been able to read from a remote database ( mssql ) thanks to the script in the tutorial. I would now like to insert a row of data to the remote mssql database. Is there a ASP script that someone can point me toward ????

any help would be appreciated

Steve
 

Stephenz43

Member
Licensed User
Longtime User
Thank you for the info...

I am a novice with asp / aspx programs and scripts. I am just trying to add ( insert ) a single row of data to a MS SQL Server database that resides on a remote server with the Android . I understand from a tutorial that MS SQL Server cannot be "talked to " directly. If that is the case when issuing a select statement, is it the same with a insert statement.
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
I use the almost same procedure with mySQL, so I suppose it's the same to execute a Select or an Insert.
 
Upvote 0

vb1992

Well-Known Member
Licensed User
Longtime User
Upvote 0

Stephenz43

Member
Licensed User
Longtime User
I have cut and paste a section of the tutorial dealing with my question. I assume the bold area needs to be changed from a reader to execute a nonquery. I am not fluent with c# so Im having difficulty

c = Request.QueryString["query"]; //for debugging with the browser
//you can set the query by adding the query parameter For ex: <a href="http://127.0.0.1/test.aspx?query=select" target="_blank">http://127.0.0.1/test.aspx?query=select</a> * 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();
Response.Write(j.Serialize(list.ToArray())
);
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…