Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
leodesol
Starting Member
9 Posts |
Posted - 2006-12-27 : 10:39:59
|
| Hello all,I am not sure if this is the proper forum, but it made sense to me to post this question here. Forgive me, but I do not do much programing. I help out with a piece of software at my work that uses a MS SQL back end to house all the data. The users of the software are not SQL people either. However, we now need to run a simple SQL statement often to make things easier, but we do not want all the users accessing the SQL server directly. All the users have an ODBC DSN connection set up already though, because of the software they use.The statement is an simple one: (example)Insert TESTDB2 (Field1, Field2)Select Field1, Field2From TESTDB1Where TESTID = '1'The problem is that I want the users of this software to be able to run this statement over the ODBC connection without actually being able to edit any of the syntax except for the Where clause.My thought is that I need to find a way to create a simple EXE or small web form to do this. As long is it is simple, a form field (for the TESTID value) and a button to execute the SQL. I figured there might even be some freeware that would help me create something like this, but I am not having any luck finding anything.So, I am just wondering if anyone on here can point me in the right direction to either some software or a tutorial that might help get me started. Or perhaps there is a better way of doing this that I am not thinking of? Any help is appreciated. |
|
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-12-27 : 12:49:08
|
You could do that fairly easily in an ASP or ASP.NET web page, but you're going to need to learn about some programming.Here's an example of a very simple ASP.NET web page that would do basically what you want - it has no error checking or anything like that, but it would work as long as you run it on a web server where ASP.NET is installed.<%@Page language="VisualBasic"%><html><head></head><body><form runat="server">Enter ID: <asp:TextBox runat="server" id="txtID"></asp:TextBox><br/><asp:Button id="btnSubmit" runat="server" onclick="btnSubmit_Click" Text="Run Query"></asp:Button><br/><asp:Label Text="" id="lblMessage" runat="server"></asp:Label></form></body></html><script runat="server">Protected Sub btnSubmit_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Dim conn As New System.Data.SqlClient.SqlConnection("data source=(local);integrated security=SSPI;initial catalog=Northwind") Dim cmd As New System.Data.SqlClient.SqlCommand("INSERT dbo.Employees1 SELECT * FROM Employees WHERE EmployeeID = @EmployeeID", conn) cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@EmployeeID", txtID.Text)) conn.Open() cmd.ExecuteNonQuery() conn.Close() lblMessage.Text = "Row/s copied for ID " & txtID.Text txtID.Text = ""End Sub</script> |
 |
|
|
leodesol
Starting Member
9 Posts |
Posted - 2006-12-27 : 13:48:18
|
| I do not mind doing to research into ASP to make this work. I think I could just modify what you posted to my needs if you where OK with that? I do not need anything fancy for now anyway.I tried to run it to see how it works, but I am unable to get it to run. I have ASP.NET on my server (the service is running for it anyway). I tried save the script example you gave me as a test.asp and I get an error that "Error Type:Active Server Pages, ASP 0221 (0x80004005)The specified 'Page language="VisualBasic"' option is unknown or invalid./WAS/VISTA/Scripttest.asp, line 1"What am I doing wrong? |
 |
|
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-12-27 : 14:22:22
|
| ASP.NET files must have a .aspx extension, not a .asp extension. |
 |
|
|
leodesol
Starting Member
9 Posts |
Posted - 2006-12-27 : 14:27:03
|
| Ah! thanks! |
 |
|
|
|
|
|
|
|