Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / January 2006

Tip: Looking for answers? Try searching our database.

imports and sqlclient

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TdarTdar - 05 Jan 2006 01:28 GMT
Hello,
I have this page however the sqlclient is not defined, i thought you just
had to put
Imports system
Imports System.Data
Imports System.Data.SqlClient

into the page but that just gives me syntax errors.

what am I missing to get sqlclient to work.

also how do i get SqlDbType command to work..

Tdar

Page as follows:

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
   <title>Untitled Page</title>
</head>
<body>
<%

   Dim cnStr As String
   cnStr =
ConfigurationManager.ConnectionStrings("SilverQueen_Main_SystemConnectionString1").ConnectionString
   Dim SqlConnection1 As New Data.SqlClient.SqlConnection(cnStr)
   
Dim backUpDB As SqlClient.SqlCommand
backUpDB = New SqlClient.SqlCommand
backUpDB.CommandType = CommandType.StoredProcedure
backUpDB.CommandText = "BackUpDBSproc"
   backUpDB.Connection = SqlConnection1
  'not sure if this is how to add parameter need to figure this out
  backUpDB.Parameter.Add("tranid", SqlDbType.Int).Value = intYear
   SqlConnection1.Open()
   backUpDB.ExecuteNonQuery()
'have to find out how to get a single response back from the sql sp...
SqlConnection1.Close()
%>
</body>
</html>
Kevin Yu [MSFT] - 05 Jan 2006 06:52 GMT
Hi Tdar,

Yes, you can import namespace into the page code like the following:

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
   <title>Untitled Page</title>
</head>
<body>
<%
   Dim cnStr As String
   cnStr =
ConfigurationManager.ConnectionStrings("SilverQueen_Main_SystemConnectionStr
ing1").ConnectionString
   Dim SqlConnection1 As New Data.SqlClient.SqlConnection(cnStr)
   
Dim backUpDB As SqlClient.SqlCommand
backUpDB = New SqlClient.SqlCommand
backUpDB.CommandType = CommandType.StoredProcedure
backUpDB.CommandText = "BackUpDBSproc"
   backUpDB.Connection = SqlConnection1
  'not sure if this is how to add parameter need to figure this out
   backUpDB.Parameters.Add("tranid", SqlDbType.Int).Value = intYear
   SqlConnection1.Open()
   backUpDB.ExecuteNonQuery()
'have to find out how to get a single response back from the sql sp...
SqlConnection1.Close()
%>
</body>
</html>

For more information, please check the following link:

http://msdn2.microsoft.com/en-us/library/eb44kack.aspx

Kevin Yu
Signature

=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

TdarTdar - 05 Jan 2006 16:30 GMT
could it not be done global from say web.config?

> Hi Tdar,
>
[quoted text clipped - 42 lines]
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
Kevin Yu [MSFT] - 06 Jan 2006 03:33 GMT
HiTdar,

Sorry, but No, it has to be done within every file.

Kevin Yu
Signature

=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.